当前位置: 首页>>代码示例>>Java>>正文


Java IUpdateHandler类代码示例

本文整理汇总了Java中org.andengine.engine.handler.IUpdateHandler的典型用法代码示例。如果您正苦于以下问题:Java IUpdateHandler类的具体用法?Java IUpdateHandler怎么用?Java IUpdateHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


IUpdateHandler类属于org.andengine.engine.handler包,在下文中一共展示了IUpdateHandler类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createActor

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
private void createActor() {
	dandelion = new TiledSprite(200, 400, res.dandelionRegion, vbom);
	dandelion.setZIndex(999);
	dandelion.registerUpdateHandler(new IUpdateHandler() {

		@Override
		public void onUpdate(float pSecondsElapsed) {
			if (dandelionBody.getLinearVelocity().y > -0.01) {
				dandelion.setCurrentTileIndex(0);
			} else {
				dandelion.setCurrentTileIndex(1);
			}
		}

		@Override
		public void reset() { }
	});
	dandelionBody = PhysicsFactory.createCircleBody(
			physics, dandelion, BodyType.DynamicBody, Constants.DANDELION_FIXTURE);
	dandelionBody.setFixedRotation(true);
	dandelionBody.setUserData(Constants.BODY_ACTOR);
	physics.registerPhysicsConnector(new PhysicsConnector(dandelion, dandelionBody));
	attachChild(dandelion);
}
 
开发者ID:sm4,项目名称:FlyingDandelion,代码行数:25,代码来源:GameScene.java

示例2: onShowScene

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public void onShowScene() {
	if (lastCharacterShown == "Ryoko") {
		character = "Sho";
	}
	else {
		character = "Ryoko";
	}
	Log.d("CharacterInfoScene", "Showing "+character+". Last character shown was "+lastCharacterShown+".");
	attachChild(new Character());
	startTime = ResourceManager.getInstance().engine.getSecondsElapsedTotal();
	updateHandler = new IUpdateHandler() {
           @Override
           public void onUpdate(float pSecondsElapsed) {
           	if (ResourceManager.getInstance().engine.getSecondsElapsedTotal() > startTime + exitDelay) {
           		unregisterUpdateHandler(updateHandler);
           		skip();
           	}            	
           }
           @Override public void reset() {}            
       };
       registerUpdateHandler(updateHandler);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:24,代码来源:CharacterIntroScene.java

示例3: readySequence

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
/**
 * Shows a Ready Message, then calls actionSecuence().
 * "Ready" is displayed 1 sec after the scene is shown and ends 1 secs before the 
 * action secuence begins.
 */
private void readySequence() {
    gameHUD.showMessage(ResourceManager.getInstance().loadAndroidRes().getString(R.string.trial_jump_ready), 1, readyTime - 1);
    mCharacter.start(); // <-
    mShineOnFloor.shine();
    timerStartedIn = ResourceManager.getInstance().engine.getSecondsElapsedTotal(); 
    trialUpdateHandler = new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            if(ResourceManager.getInstance().engine.getSecondsElapsedTotal() >
            timerStartedIn + readyTime) {
                TrialSceneJump.this.unregisterUpdateHandler(trialUpdateHandler);
                actionSequence();
              }
        }
        @Override public void reset() {}
    };
    registerUpdateHandler(trialUpdateHandler);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:24,代码来源:TrialSceneJump.java

示例4: readySequence

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
/**
 * Shows a Ready Message, then calls actionSecuence().
 * "Ready" is displayed 1 sec after the scene is shown and ends 1 secs before the 
 * action secuence begins.
 */
private void readySequence() {
    gameHUD.showMessage(ResourceManager.getInstance().loadAndroidRes().getString(R.string.trial_cut_ready), 1, readyTime - 1);
    timerStartedIn = ResourceManager.getInstance().engine.getSecondsElapsedTotal(); 
    trialUpdateHandler = new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            if(ResourceManager.getInstance().engine.getSecondsElapsedTotal() >
            timerStartedIn + readyTime) {
                TrialSceneCut.this.unregisterUpdateHandler(trialUpdateHandler);
                actionSequence();
              }
        }
        @Override public void reset() {}
    };
    registerUpdateHandler(trialUpdateHandler);
    
    //gameHUD.showAchievementCompleted(1);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:24,代码来源:TrialSceneCut.java

示例5: actionSequence

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
/**
 * Main trial secuence. Shows a "Cut!" message, starts the Chronometer and enables the cut.
 */
protected void actionSequence() {
    trialUpdateHandler = new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            if(chrono.isTimeOut()) {
                TrialSceneCut.this.unregisterUpdateHandler(trialUpdateHandler);
                timeOut();
            }
        }
        @Override public void reset() {}
    };
    registerUpdateHandler(trialUpdateHandler);
    gameHUD.showMessage(ResourceManager.getInstance().loadAndroidRes().getString(R.string.trial_cut_go), 0, 1);
    chrono.start();
    precisionBar.start();
    cutEnabled = true;
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:21,代码来源:TrialSceneCut.java

示例6: registerUpdateHandler

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) {
	if (this.mUpdateHandlers == null) {
		this.allocateUpdateHandlers();
	}
	this.mUpdateHandlers.add(pUpdateHandler);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:8,代码来源:Entity.java

示例7: unregisterUpdateHandler

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler) {
	if (this.mUpdateHandlers == null) {
		return false;
	}
	return this.mUpdateHandlers.remove(pUpdateHandler);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:8,代码来源:Entity.java

示例8: registerUpdateHandler

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) {
	if(this.mUpdateHandlers == null) {
		this.allocateUpdateHandlers();
	}
	this.mUpdateHandlers.add(pUpdateHandler);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:8,代码来源:Entity.java

示例9: unregisterUpdateHandler

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public boolean unregisterUpdateHandler(final IUpdateHandler pUpdateHandler) {
	if(this.mUpdateHandlers == null) {
		return false;
	}
	return this.mUpdateHandlers.remove(pUpdateHandler);
}
 
开发者ID:peterchaula,项目名称:ClassicF1,代码行数:8,代码来源:Entity.java

示例10: createPlayer

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
private void createPlayer() {
    player = new Player(150, 240, 0, activity.getTexture(ResMan.GUT_BACTMAN), activity);
    final Scene scene = activity.getScene();
    scene.getChildByIndex(AbstractGameActivity.LAYER_FOREGROUND).attachChild(player.getSprite());
    scene.registerUpdateHandler(new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            //TODO: Merge with Bin.Item's checkPosition()
            final Body body = player.getBody();
            final Vector2 initialPosition = player.getInitialPosition();
            float x = body.getPosition().x;
            float y = body.getPosition().y;

            if (x < 0 || y < 0 || x > LandscapeGameActivity.CAMERA_WIDTH || y > LandscapeGameActivity.CAMERA_HEIGHT) {
                Log.d(TAG, "onUpdate - Position is out of screen!");

                body.setTransform(initialPosition.x / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT,
                            initialPosition.y / PhysicsConstants.PIXEL_TO_METER_RATIO_DEFAULT, body.getAngle());
                }
        }

        @Override
        public void reset() {

        }
    });
}
 
开发者ID:PLNech,项目名称:BactMan-Adventures,代码行数:28,代码来源:GutGame.java

示例11: deathEvent

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
private void deathEvent(){
	rm.isDie = true;
	rm.animatedSprite_panda.setRotation(180);
	sortChildren();
	registerUpdateHandler(new IUpdateHandler() {
		@Override
		public void reset() {

		}

		@Override
		public void onUpdate(float pSecondsElapsed) {
			try {
				Thread.sleep(rm.speed);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}

			rm.animatedSprite_panda.setPosition(rm.animatedSprite_panda.getX(), rm.animatedSprite_panda.getY() + 30);
			if (rm.animatedSprite_panda.getY() >= Constants.height -(rm.panda_width * rm.panda_scale / 2)) {
				setIgnoreUpdate(true);
				rm.mDie.play();
				showScore();
			}
		}
	});
}
 
开发者ID:thoinv,项目名称:kaorisan,代码行数:28,代码来源:GameScene.java

示例12: showResults

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
/**
 * Show one score item each time, and the growing score.
 * Finally adds the score to the main game score.
 */
private void showResults() {
    drawings.setVisible(true);
    tittleText.setVisible(true);
    stamp.setVisible(true);
    scoreItemArrayIndex = 0;        

    updateHandler = new IUpdateHandler() {
        @Override
        public void onUpdate(float pSecondsElapsed) {
            if(growingScore.isFinished())
                if(scoreItemArrayIndex < scoreItemsNumber) {
                    growingScore.addScore(scoreItemArray[scoreItemArrayIndex].addedPoints);
                    addScoreLine(SCORE_ROW_HEIGHT - SCORE_ROW_GAP * scoreItemArrayIndex,
                        scoreItemArray[scoreItemArrayIndex].description,
                        scoreItemArray[scoreItemArrayIndex].value);
                    scoreItemArrayIndex++;                    
                }
                else {
                    // No more rows to show.
                    ResultWinScene.this.unregisterUpdateHandler(updateHandler);
                }
        }
        @Override public void reset() {}
    };
    registerUpdateHandler(updateHandler);

    // Add the trial score to the total score:
    GameManager.incrementScore(TrialSceneCut.getScore());
    
    // Sounds:
    SFXManager.playSound(ResourceManager.getInstance().winYouWin);
    SFXManager.playMusic(ResourceManager.getInstance().winMusic);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:38,代码来源:ResultWinScene.java

示例13: launch

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
public void launch(float fromX) {
	for (Sprite shuriken: shurikenSprites) {
		shuriken.setX(fromX);
	}
	shurikenAnimationCounter = 0;
	shurikenLaunchTime = ResourceManager.getInstance().engine.getSecondsElapsedTotal();
	shurikenUpdateHandler = new IUpdateHandler() {
           @Override
           public void onUpdate(float pSecondsElapsed) {
           	float period = .12f;
               if(ResourceManager.getInstance().engine.getSecondsElapsedTotal() >
               shurikenLaunchTime + period*shurikenAnimationCounter) {
               	if (shurikenAnimationCounter == 0) {
               		shurikenSprites[5-shurikenAnimationCounter].setAlpha(1f);
               	}
               	else if (shurikenAnimationCounter == 6) {
               		shurikenSprites[0].setAlpha(0f);
               		ShurikenShuriken.this.unregisterUpdateHandler(shurikenUpdateHandler);
               	}
               	else {
               		shurikenSprites[5-shurikenAnimationCounter+1].setAlpha(0f);
               		shurikenSprites[5-shurikenAnimationCounter].setAlpha(1f);
               	}
               	shurikenAnimationCounter++;
               }	                
           }
           @Override public void reset() {}
       };
       registerUpdateHandler(shurikenUpdateHandler);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:31,代码来源:ShurikenShuriken.java

示例14: start

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
/**
 * Shows Ready and Go messages and then starts the game.
 */
private void start() {
	gameStartTime = ResourceManager.getInstance().engine.getSecondsElapsedTotal();
	trialUpdateHandler = new IUpdateHandler() {
           @Override
           public void onUpdate(float pSecondsElapsed) {
           	float waitPeriodForReadyMsg = 2f;
           	float waitPeriodForGoMsg = 5f;
               if(ResourceManager.getInstance().engine.getSecondsElapsedTotal() >
               gameStartTime + waitPeriodForReadyMsg) {
               	if (!readyShow){
               		readyShow = true;
               		gameHUD.showMessage(ResourceManager.getInstance().loadAndroidRes().getString(R.string.trial_shuriken_ready), 0, 2);
               	}
               }
               if(ResourceManager.getInstance().engine.getSecondsElapsedTotal() >
               gameStartTime + waitPeriodForGoMsg) {
                   TrialSceneShuriken.this.unregisterUpdateHandler(trialUpdateHandler);
                   gameHUD.showMessage(ResourceManager.getInstance().loadAndroidRes().getString(R.string.trial_shuriken_go), 0, 1);
                   gameStarted = true;
                   SFXManager.playMusic(ResourceManager.getInstance().trialShurikens);
                   generateEnemies();
                   checkEnemiesStatus();
                   gameStartTime = ResourceManager.getInstance().engine.getSecondsElapsedTotal();
               }
           }
           @Override public void reset() {}
       };
       registerUpdateHandler(trialUpdateHandler);
}
 
开发者ID:jjhaggar,项目名称:ninja-trials,代码行数:33,代码来源:TrialSceneShuriken.java

示例15: registerUpdateHandler

import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) {
	this.mMenuItem.registerUpdateHandler(pUpdateHandler);
}
 
开发者ID:ArturVasilov,项目名称:AndroidCourses,代码行数:5,代码来源:BaseMenuItemDecorator.java


注:本文中的org.andengine.engine.handler.IUpdateHandler类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。