i want to move a sprite to a position which i touch.
that`s my code but it crashes I don`t why
i want to move a sprite by touching the screen to that point but my app crashes
public class GameLayer extends CCLayer {
static final int kTagSprite = 1;
public static CCScene scene()
{
CCScene scene = CCScene.node();
CCLayer layer = new GameLayer();
scene.addChild(layer);
return scene;
}
protected GameLayer()
{
this.setIsTouchEnabled(true);
CCSprite player2 = CCSprite.sprite(“Yellow.png”) ;
player2.setPosition(CGPoint.ccp(150 , 150));
addChild(player2 , kTagSprite );
}
@Override
public boolean ccTouchesBegan(MotionEvent event) {
//create point takes coordinates of touch
CGPoint convertedLocation = CCDirector.sharedDirector()
.convertToGL(CGPoint.make(event.getX(), event.getY()));
CCNode s = getChild(kTagSprite);
s.stopAllActions();
s.runAction(CCMoveTo.action(1.0f, convertedLocation));
return CCTouchDispatcher.kEventHandled;
}
}