Spritebuilder achieve 2D Sprite light and shade Reflection effect (ii)

Source: Internet
Author: User

Create a new project with Spritebuilder and delete the contents of the default MAINSCENE.CCB, and the scene should be dark.

The 2 pictures in the flag net and all 2 of my own pictures are dragged to their file view:

Where the _n suffix image represents the normal map of the original.

Drag 2 images without _n suffix to the black scene and adjust to the appropriate position.
Set the 2 Wizard's normal map to the corresponding picture of the _n suffix, respectively:

Open the lighting effects for 2 sprites, respectively. At this point, you can see the effect of light and shadow, but then Spritebuilder give you The "illusion", if the app is compiled and run at this time, can only see the Dark one, because at this point has not added any lights.

Dragging a light node node into the scene from the control library is equivalent to adding a lighting source to the scene. You will find that with the movement of the light source, there is a noticeable change in the lighting of the 2 sprites:

To simulate more realism, drag a particle effect node from the Control Library. Adjust it to a flame. Put the particle node in a ccnode with the light node above, and set the node's code to connect to _firenode.

Then open the MAINSCENE.M file in Xcode, enable touch, and then set up the corresponding touch callback method:

-(void)touchMoved:(CCTouch *)touch withEvent:(CCTouchEvent *)event{    CGPoint location = [[CCDirector sharedDirector] convertTouchToGL:touch];    _fireNode.position = location;}

Compile and run the app and you can see the actual effect as follows:

The end of this article.

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Spritebuilder achieve 2D Sprite light and shade Reflection effect (ii)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.