本文整理匯總了Java中com.badlogic.gdx.utils.Timer類的典型用法代碼示例。如果您正苦於以下問題:Java Timer類的具體用法?Java Timer怎麽用?Java Timer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Timer類屬於com.badlogic.gdx.utils包,在下文中一共展示了Timer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: sendOpenSessionEvent
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
protected void sendOpenSessionEvent() {
if (!isSessionActive())
return;
Map<String, String> params = new HashMap<String, String>();
addGameIDUserNameUserToken(params);
final Net.HttpRequest http = buildJsonRequest("sessions/open/", params);
if (http != null)
Gdx.net.sendHttpRequest(http, new NoOpResponseListener());
pingTask = Timer.schedule(new Timer.Task() {
@Override
public void run() {
sendKeepSessionOpenEvent();
}
}, GJ_PING_INTERVAL, GJ_PING_INTERVAL);
}
示例2: create
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void create()
{
enemyStack = new Stack<Enemy>();
Timer.schedule(new Task()
{
@Override
public void run()
{
int choiceToMove = MathUtils.random(3);
for(int i = 0; i < 5; i++)
{
enemyStack.add(new WeakEnemy(choiceToMove, xOffset * i, yOffset * i));
}
//Timer.instance().clear();
}
}, 0.5f, intervalBetweenSpawn);
}
示例3: downenergy
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void downenergy(int value){
bar.act(Gdx.graphics.getDeltaTime());
infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy() - value);
FadeIn();
new Timer().schedule(new Timer.Task() {
@Override
public void run() {
bar.setAnimateDuration(3);
bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
mapsScreen.startTimer();
}
}, 1000);
}
示例4: update
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void update() {
bar.act(Gdx.graphics.getDeltaTime());
infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy());
username.setText("L "+infoProfile.getDateUserGame().getLevel()+" "+infoProfile.getDateUser().getFristName());
bar.setValue(infoProfile.getDateUserGame().getEnergy() - infoProfile.getValueenergyuse());
FadeIn();
new Timer().schedule(new Timer.Task() {
@Override
public void run() {
bar.setAnimateDuration(3);
bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
e.printStackTrace();
}
if(infoProfile.getDateUserGame().getEnklaveCombatId() == -1)
mapsScreen.startTimer();
}
} ,1);
}
示例5: screenExit
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void screenExit(String message){
messageShow = message;
showtextexit = true;
circleShow = false;
InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
Label labelmess = new Label("You already joined this combat once!",new Label.LabelStyle(bitmapFont,Color.WHITE));
labelmess.setPosition(WIDTH /2 - labelmess.getWidth() /2,labelmess.getHeight()*2);
stage.addActor(labelmess);
combatFight.deselect();
attachers.deselect();
defenders.deselect();
if(!message.contentEquals("You lose!")){
new Timer().scheduleTask(new Timer.Task() {
@Override
public void run() {
managerAssets.getAssertEnklaveScreen().setIsupdate(false);
new GetEnklaveDetails().makeRequest(InformationEnklave.getInstance().getId(), managerAssets);
// gameManager.setScreen(gameManager.screenEnklave);
}
},1);
}
}
示例6: setUpPlayButton
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setUpPlayButton() {
playButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "playbtn", false);
playButton.setPosition(Constants.WIDTH / 4 - playButton.getWidth() * 2 / 5,
Constants.HEIGHT / 2 - playButton.getHeight() * 2.5f -2);
playButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
//FlappySpinner.gameManager.hideAd();
float delay = 0.3f;
setUpFadeOut();
Timer.schedule(new Timer.Task() {
@Override
public void run() {
game.setScreen(new GameScreen(game, 0, false));
}
}, delay);
}
});
stage.addActor(playButton);
}
示例7: setUpMarketButton
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setUpMarketButton() {
marketButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "market", false);
marketButton.setPosition(Constants.WIDTH * 3 / 4 - marketButton.getWidth() * 3 / 5,
Constants.HEIGHT / 2 - marketButton.getHeight() * 2.5f - 2);
marketButton.addListener(new ChangeListener() {
@Override
public void changed(ChangeEvent event, Actor actor) {
float delay = 0.3f;
setUpFadeOut();
Timer.schedule(new Timer.Task() {
@Override
public void run() {
game.setScreen(new MarketScreen(game));
}
}, delay);
}
});
stage.addActor(marketButton);
}
示例8: setTimersAndTasks
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setTimersAndTasks()
{
endTask = new Timer.Task()
{
public void run()
{
Gdx.app.log("timer", "Ending game");
endGameWorld(won());
}
};
endClock = new CGCTimer(endTask, endTime, false, "endClock");
respawnTask = new Timer.Task()
{
public void run()
{
respawnHeight = getPlayerAverageY();
}
};
respawnClock = new CGCTimer(respawnTask, CAMERA_DELAY, (int)respawnTime * 60);
respawnClock.name = "respawnClock";
}
示例9: Helicopter
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public Helicopter(CGCWorld theWorld, Animation newLowAnimation, Animation newMidAnimation,
Animation newHighAnimation, EntityType entityType, Body body)
{
super(newLowAnimation, newMidAnimation, newHighAnimation, entityType, body);
gameWorld = theWorld;
Gdx.app.log("In the pipe", "five by five");
rotation = 90;
//SoundManager.playSound("helicopter", false);
hoverTask = new Timer.Task() {
public void run()
{
stopped = false;
returnTrip = true;
getBody().setLinearVelocity(new Vector2(4,0));
}
};
hoverClock = new CGCTimer(hoverTask, hoverTime, false, "hoverClock");
body.setLinearVelocity(new Vector2(4, 0));
}
示例10: RookieCop
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public RookieCop(CGCWorld theWorld, CharacterArt art, EntityType pEntityType, Body attachedBody, short pID) {
super(art, pEntityType, attachedBody, pID);
gameWorld = theWorld;
maxGrabStrength = MAX_GRAB_STRENGTH_BASE + Math.round(((float)(Math.random() * 2) - 1.0f) * MAX_GRAB_RANGE);
currentGrabStrength = maxGrabStrength;
noGrab = false;
setCoins(0);
grabCooldownTask = new Timer.Task()
{
public void run()
{
currentGrabStrength = maxGrabStrength;
noGrab = false;
}
};
grabCooldownTimer = new CGCTimer(grabCooldownTask, grabCooldown, false, "grabCooldownTimer");
}
示例11: Sheriff
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public Sheriff(Animation newLowAnimation, Animation newMidAnimation,
Animation newHighAnimation, EntityType pEntityType,
Body attachedBody, Boss bo, float startAlpha)
{
super(newLowAnimation, newMidAnimation, newHighAnimation, pEntityType,
attachedBody, startAlpha);
boss = bo;
fireTask = new Timer.Task()
{
public void run()
{
fire();
}
};
fireTimer = new CGCTimer(fireTask, fireTime, true, "fireTimer");
do
{
target = CGCWorld.getPrisoners().random();
}while(!target.isAlive() || target == null);
TimerManager.addTimer(fireTimer);
}
示例12: SoundEffect
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public SoundEffect(FileHandle f)
{
mySound = Gdx.audio.newSound(f);
playTime = (float)(f.length())/(float)(16384);
playTask = new Timer.Task() {
public void run()
{
if(!looping)
{
playing = false;
paused = false;
}
}
};
playTimer = new CGCTimer(playTask, playTime, looping, "playTimer");
}
示例13: setUpTimer
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
private void setUpTimer()
{
hidePromptTask = new Timer.Task()
{
public void run()
{
if (yDisplacement < creditsBottom)
{
showButtonPrompt = false;
}
}
};
autoScrollTask = new Timer.Task()
{
public void run()
{
autoScroll = true;
}
};
hidePromptTimer = new CGCTimer(hidePromptTask, hidePromptTime, false, "hidePromptTimer");
autoScrollTimer = new CGCTimer(autoScrollTask, autoScrollTime, false, "autoScrollTimer");
}
示例14: keepAttacking
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void keepAttacking() {
changeState(Enemy.State.ATTACKING, 1, new GameObject.OnAnimationComplete() {
@Override public void run(GameObject object) {
changeState(Enemy.State.STANDING);
}
});
context.removeLife();
if(context.life.isEmpty()) return;
int randomAttack = (int) Math.floor(context.soundsEffectEnemyAttack.size()*Math.random());
context.soundsEffectEnemyAttack.get(randomAttack).play();
Timer.schedule(new Timer.Task() {
@Override
public void run() {
if(!state.equals(Enemy.State.DYING))
keepAttacking();
}
}, TIME_TO_ATTACK);
}
示例15: die
import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void die() {
final Enemy enemy = this;
enabled = false;
context.tweenManager.killTarget(this, GameObjectAccessor.XYZ);
context.tweenManager.killTarget(this, GameObjectAccessor.ROTATION);
changeState(Enemy.State.DYING, 1);
Timer.schedule(new Timer.Task() {
@Override
public void run() {
Vector3 position = enemy.transform.getTranslation(new Vector3());
enemy.moveToAnimation(position.x, -0.5f, position.z, 2, new GameObject.OnAnimationComplete() {
@Override public void run(GameObject object) {
context.instances.remove(enemy);
}
});
}
}, TIME_TO_ATTACK);
}