我是 cocos2d 的新手,我想知道如何在 java 中编写代码来检查我是否接触过我已经尝试过这样的精灵。
@Override
public boolean ccTouchesEnded(MotionEvent event)
{
CGPoint location = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(event.getX(), event.getY()));
if ((location.x == zom.getPosition().x) && (location.y == zom.getPosition().y))
{
CCSprite projectile = CCSprite.sprite("bullet.png");
projectile.setPosition(CGPoint.ccp(player.getPosition().x,player.getPosition().y));
addChild(projectile);
float length = (float)Math.sqrt((100 * 100) + (100 * 100));
float velocity = 100.0f / 1.0f;
float realMoveDuration = length / velocity;
projectile.runAction(CCSequence.actions(
CCMoveTo.action(realMoveDuration, CGPoint.ccp(location.x, location.y)),
CCCallFuncN.action(this, "spriteMoveFinished")));
if ((projectile.getPosition().x == location.x) && ( projectile.getPosition().y == location.y))
{
removeChild(projectile, true);
}
}