0

cocos2d-android でスプライト (カノン) をタッチし、そのタッチに反応 (弾丸を発射) するためにthis.setIsTouchEnabled(true);、コンストラクターで設定し、ccToouchesBegan() で以下のコードを追加しました

@Override
public boolean ccTouchesBegan(MotionEvent event)    
{  

    canon1 = CCSprite.sprite("android.png");
     canon1.setPosition(CGPoint.ccp(10, 60));
     canon1.setScale(1f);
    addChild(canon1);

    CGRect canon1Rect = CGRect.make(canon1.getPosition().x - (canon1.getContentSize().width/2),
            canon1.getPosition().y - (canon1.getContentSize().height/2),
            canon1.getContentSize().width,
            canon1.getContentSize().height);

    // Choose one of the touches to work with
    CGPoint location = CCDirector.sharedDirector().convertToGL(CGPoint.ccp(10,60));

return;
}

そのため、スプライト (大砲) の弾丸に触れると発射する必要がありますが、ここではタッチが機能していません。

4

1 に答える 1