home

2014년 8월 14일 목요일

[AndEngine] 3. Touch Event


@Override
protected Scene onCreateScene() {
    scene = new Scene();
    scene.setBackground(new Background(0.f, 0.f, 0.f));
    final VertextBufferObjectManager vertexBufferObjectManager
        = this.getVertexBufferObjectManager();

    appleSprite = new Sprite(10, 130, this.mImgObjBehind, vertexBufferObjectManager);
    backSprite = new Sprite(10, 130, this.mImgObj, vertexBufferObjectManager);

    scene.attchChild(bakSprite);
    scene.setOnScreenTouchListener(this);
 
    return scene;
}

@Override
public boolean onScreenTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
    if(pSceneTouchEvent.isActionDown() {
        scene.detachChild(backSprite);
        scene.attachChild(appleSprite);
        return true;
    }
    return false;
}

댓글 없음:

댓글 쓰기