本文整理汇总了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);
}
示例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);
}
示例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);
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
示例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() {
}
});
}
示例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();
}
}
});
}
示例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);
}
示例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);
}
示例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);
}
示例15: registerUpdateHandler
import org.andengine.engine.handler.IUpdateHandler; //导入依赖的package包/类
@Override
public void registerUpdateHandler(final IUpdateHandler pUpdateHandler) {
this.mMenuItem.registerUpdateHandler(pUpdateHandler);
}