开发者

Create multi-sprite with multi-touch?

I'm using AndEngine multi-touch functions to create multi-sprite for my game. But I've a problem:

  • When I create the sprite (in the Scene touch down event), I call its StartGrowSize method.
  • When user stops touching (release his/her finger) at a sprite, I need call its StopGrowSize method.

The problem is, I CAN'T determine when the user releases her finger, and which finger (the finger that create that sprite).

This is some code in my game:

@Override
public boolean onSceneTouchEvent(Scene arg0, TouchEvent arg1) {
    if (arg1.isActionDown()) {
        //Create a balloon
        int balloonType = rndGenerator.nextInt(GlobalStatic.BalloonTypeTotal);
        currentBalloon = new clsBalloon(arg1.getX(), arg1.getY(), 
            ANDBallonTextureRegion[balloonType].clone(), balloonType, this);
        balloons.add(currentBalloon);

        scnGameScene.ettBalloon.attachChild(currentBalloon);
    } 
    return true;
}

In the clsBalloon:

    @Override
public boolean onAreaTouched(TouchEvent pSceneTouchEvent,
        float 开发者_运维问答pTouchAreaLocalX, float pTouchAreaLocalY) {
    if (pSceneTouchEvent.isActionUp()) {
        StopGrowSize();
        return true;
    }
    return super.onAreaTouched(pSceneTouchEvent, pTouchAreaLocalX, pTouchAreaLocalY);
}

But it didn't work. Please help me, thank you.


OK, so now my solution is that create a pre-sprite that fill the screen and register its touch handler, resize and set its new face.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜