Game Development Reference
In-Depth Information
As you can see in Listing 5-18 , you can use CCMotionStreak to draw a slowly fad-
ing line, where a texture is stretched to the entire length of the line. For example, you
can use this to create high-speed bullets that stretch out the faster they move. Listing
5-19 shows the code to create and move a CCMotionStreak node to the location of
a touch. In the Parallax01 project, you can touch the screen to draw a motion streak
Listing 5-18. The CCMotionStreak Creates a Line Stroke Effect
-(void) resetMotionStreak
// Removes the CCMotionStreak and creates a new one.
[self removeChildByTag:ParallaxSceneTagMotionStreak cleanup:YES];
CCMotionStreak* streak = [CCMotionStreak streakWithFade:0.99f
color:ccc3(255, 0, 255)
[self addChild:streak z:5 tag:ParallaxSceneTagMotionStreak];
streak.blendFunc = (ccBlendFunc){GL_ONE, GL_ONE};
-(CCMotionStreak*) getMotionStreak
CCNode* node = [self getChildByTag:ParallaxSceneTagMotionStreak];
NSAssert([node isKindOfClass:[CCMotionStreak class]], @"not a CCMotionStreak");
return (CCMotionStreak*)node;
-(CGPoint) locationFromTouch:(UITouch*)touch
CGPoint touchLocation = [touch locationInView: [touch view]];
return [[CCDirector sharedDirector] convertToGL:touchLocation];
-(void) moveMotionStreakToTouch:(UITouch*)touch
Search Nedrilad ::

Custom Search