home

2014년 8월 15일 금요일

[AndEngine] 7. Jump

onCreateScene() {
    ....
    final Jump jump = new Jump(center_X, center_Y, this.mFaceTextureRegionJump, this.getVertexBufferObjectManager());
    scene.attachChild(jump);

    return scene;
}

private static class Jump extends AnimatedSprite {
    private final PhysicsHandler mPhysicsHandler;

    public Jump(final float pX, final float pY, final TiledTextureRegion pTextureRegion, final VertexBufferObjectManger pVertexBufferObjectManager) {
        super(pX, pY, pTextureRegion, pVertexBufferObjectManager);
        this.mPhysicsHandler = new PhysicsHandler(this);
       
        this.mPhysicsHandler.setVelocityY(JumpSample.DEMO_VELOCITY);
    }
    @Override
    protected void onManagedUpdate(final float pSecondsElapsed) {
        ....
        this.mPhysicsHandler.setVelocityY(JumpSample.DEMO_VELOCITY);//+
        this.mPhysicsHandler.setVelocityY(-JumpSample.DEMO_VELOCITY);//-
    }
}

댓글 없음:

댓글 쓰기