simple cocos2d game에 대한 지침서를 작성 중입니다. 그에 그러나탄창/탄환 방향 Cocos2d
는
내가 그것은 단지 하나의 단면 모든 방향에서 발사하기 위해 할 수있는 사용자 화재가 한 방향에 있는지 총알 튜토리얼?
여기에 방향 코드가 있습니다.
int offX = location.x - projectile.position.x;
int offY = location.y - projectile.position.y;
[self addChild:projectile];
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);
int offRealX = realX - projectile.position.x;
int offRealY = realY - projectile.position.y;
float length = sqrtf((offRealX*offRealX)+(offRealY*offRealY));
float velocity = 480/1;
float realMoveDuration = length/velocity;
[projectile runAction:[Sequence actions:[MoveTo actionWithDuration:realMoveDuration position:realDest],
[CallFuncN actionWithTarget:self selector:@selector(spriteMoveFinished:)], nil]];
모든 도움을 주시면 대단히 감사하겠습니다. 감사합니다
나는 또한 레이의 블로그에서 cocos2d를 배우고 있습니다. 심지어 내가 대답을 알고 싶습니다 .. :) – Sarah
확인 돌봐 : – NoobMe