0

嘿伙计们,我正在关注这段代码

final AnimatedSprite mySprite = new AnimatedSprite(100, 220, this.mySpriteTextureRegion) {
            @Override
            public boolean onAreaTouched(final TouchEvent pSceneTouchEvent, final float pTouchAreaLocalX, final float pTouchAreaLocalY) {
                this.setPosition(pSceneTouchEvent.getX() - this.getWidth() / 2, pSceneTouchEvent.getY() - this.getHeight() / 2);
                        int eventaction = event.getAction(); 

                    float X = event.getX();
                    float Y = event.getY();

                    switch (eventaction) {
                       case TouchEvent.ACTION_DOWN:
                    break;
                       case TouchEvent.ACTION_MOVE: {
                            this.setPosition(X, Y);
                            break;}
                       case TouchEvent.ACTION_UP:
                            break;
                    }
            return true;
        }
    };

但使用 Sprite 而不是 AnimatedSprite

但是当我在手机上测试它时,精灵不动......

我做错了什么??

4

1 回答 1

1

你缺这些吗?

registerTouchArea(mySprite);
setTouchAreaBindingOnActionDownEnabled(true);
于 2013-11-30T05:45:52.783 回答