37 float velocity = 480/1; // 480pixels/1sec
38 float realMoveDuration = length/velocity;
39
40 // Move projectile to actual endpoint
41 projectile->runAction( CCSequence::actions(
42 CCMoveTo::actionWithDuration(realMoveDuration, realDest),
43 CCCallFuncN::actionWithTarget(this,
44
45 callfuncN_selector(HelloWorld::spriteMoveFinished)),
46 NULL) );
47}
1// objc with cocos2d-iphone
2- (void)ccTouchesEnded:(NSSet *)touches withEvent:(UIEvent* event)
3{
4 // Choose one of the touches to work with
5 UITouch *touch = [touches anyObject];
6 CGPoint location = [touch locationInView:[touch view]];
7 location = [[CCDirector sharedDirector] convertToGL:location];
8
9 // Set up initial location of projectile
10 CGSize winSize = [[CCDirector sharedDirector] winSize];
11 CCSprite *projectile = [CCSprite spriteWithFile:@"Projectile.png"
12 rect:CGRectMake(0, 0, 20, 20)];