Game Development Reference
In-Depth Information
{
CCMotionStreak* streak = [self getMotionStreak];
streak.position = [self locationFromTouch:touch];
}
-(BOOL) ccTouchBegan:(UITouch*)touch withEvent:(UIEvent *)event
{
[self moveMotionStreakToTouch:touch];
// Always swallow touches.
return YES;
}
-(void) ccTouchMoved:(UITouch*)touch withEvent:(UIEvent *)event
{
[self moveMotionStreakToTouch:touch];
}
The fade parameter of CCMotionStreak determines how fast ribbon elements
fade out—the smaller the number, the quicker they disappear, and the shorter the line
will be. The minSeg parameter apparently modifies how many segments the line con-
sists of at a minimum. However, it has almost no discernable effect, though it shouldn't
be too low to prevent graphical glitches like gaps in the streak, nor too high (dozens or
more) to avoid performance issues. The color is used to tint the texture.
Tip If you're interested in creating a line-drawing game similar to Flight Con-
trol or Harbor Master, then CCMotionStreak won't help you draw the
line—literally speaking, of course. The problem is that motion streak lines dis-
appear quickly. Instead you should check out the Line-Drawing Game Starterkit
that I'm selling: www.learn-cocos2d.com/store/line-drawing-
game-starterkit . It contains all the code necessary to draw paths with
your finger, drawing lines with OpenGL and having an object follow that
line—among other things.
Summary
Search Nedrilad ::




Custom Search