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)