如何让精灵在被触摸时做某事(具体来说,我希望它的大小增加。)我试过:
private void createSpriteOnTap(float x, float y)
{
final Sprite yourSprite = new Sprite(x, y, textureRegionForYourSprite, getVertexBufferObjectManager())
{
@Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent, float pTouchAreaLocalX, float pTouchAreaLocalY)
{
//if(pSceneTouchEvent.isActionDown()){
if (pSceneTouchEvent.isActionMove())
{
// while player is touching our sprite
setScale(scale += 0.1);
setPosition(pSceneTouchEvent.getX() - getWidth() / 2, pSceneTouchEvent.getY() - getHeight() / 2);
}
if(pSceneTouchEvent.isActionDown())
setScale(scale += 0.1);
return true;
}
};
但是精灵只有在移动或被点击时才会增加大小,而不是被握住。在用户抬起手指之前,如何使其尺寸增加?