We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,280 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

CCSprite movement problem

int realX = winSize.width + (projectile.contentSize.width/2);
float ratio = (float) offY / (float) offX;
int realY = (realX * ratio) + projectile.position.y;
CGPoint realDest = ccp(realX, realY);
[_projectiles addObject:projectile];
projectile.tag = 2;


[projectile runAction:[CCSequence actions:
                       [CCMoveTo actionWithDuration:realMoveDuration position:realDest],
                       [CCCallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)],
                       nil]];

In this simple app, I am trying to make a projectile flying from the middle of the screen to wherever the user touches, and beyond, to the edge of the screen. For whatever reason, the projectile will only fly to destinations with positive x coordinates, no matter when the user presses. If you imagine an x y plane, with the center of the screen (and at this point, the only spot the player can be) being origin, the projectile will only fly to places on in the quadrants to the right of origin. If the user touches a point on the left two, the projectile flies in the opposite direction, on the same slope as the ratio of the touch to origin. .... .........? Any ideas, thanks in advance

2
Contributors
0
Replies
1
View
Rickay
Junior Poster in Training
55 posts since Jul 2010
Reputation Points: 5
Solved Threads: 0
Skill Endorsements: 0

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0571 seconds using 2.67MB