org.andengine.entity.scene.IOnSceneTouchListener Java Examples

The following examples show how to use org.andengine.entity.scene.IOnSceneTouchListener. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LevelModeCompleteScene.java    From sopa with Apache License 2.0 6 votes vote down vote up
LevelModeCompleteScene() {

        Text levelCompleteTextShape = new Text((float) (camera.getWidth() * 0.05), (float) (camera.getHeight() * 0.05),
                resourcesManager.levelModeCompleteFont, "Level Mode\nCompleted", vbom);
        levelCompleteTextShape.setScaleCenter(0, 0);
        attachChild(levelCompleteTextShape);

        Sprite cup = new Sprite(0, 0, resourcesManager.levelModeCup, vbom);
        cup.setPosition(camera.getWidth() / 2 - cup.getWidth() / 2, camera.getHeight() * 0.4f);
        attachChild(cup);
        attachChild(new ConfettiParticleSystem(vbom, camera.getWidth()));
        setOnSceneTouchListener(new IOnSceneTouchListener() {

                @Override
                public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {

                    onBackKeyPressed();

                    return false;
                }
            });
    }
 
Example #2
Source File: MainActivity.java    From OpenFlappyBird with Do What The F*ck You Want To Public License 4 votes vote down vote up
@Override
protected Scene onCreateScene() {				

	mBackground = new ParallaxBackground(82/255f, 190/255f, 206/255f){

		float prevX = 0;
		float parallaxValueOffset = 0;

		@Override
		public void onUpdate(float pSecondsElapsed) {

			switch(GAME_STATE){

			case STATE_READY:
			case STATE_PLAYING:
				final float cameraCurrentX = mCurrentWorldPosition;//mCamera.getCenterX();

				if (prevX != cameraCurrentX) {

					parallaxValueOffset +=  cameraCurrentX - prevX;
					this.setParallaxValue(parallaxValueOffset);
					prevX = cameraCurrentX;
				}
				break;
			}		

			super.onUpdate(pSecondsElapsed);
		}
	};

	mSceneManager = new SceneManager(this, mResourceManager, mBackground);
	mScene = mSceneManager.createScene();	

	mScene.setOnSceneTouchListener(new IOnSceneTouchListener() {

		@Override
		public boolean onSceneTouchEvent(Scene pScene, TouchEvent pSceneTouchEvent) {
			if(pSceneTouchEvent.isActionDown()){

				switch(GAME_STATE){

				case STATE_READY:
					startPlaying();
					break;

				case STATE_PLAYING:
					mSceneManager.mBird.flap();
					break;

				case STATE_DEAD:
					//restartGame();
					break;	
				}								
			}
			return false;
		}
	});		
	
	updateScore();

	return mScene;
}