本文整理匯總了Java中com.badlogic.gdx.utils.Timer.schedule方法的典型用法代碼示例。如果您正苦於以下問題:Java Timer.schedule方法的具體用法?Java Timer.schedule怎麽用?Java Timer.schedule使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.badlogic.gdx.utils.Timer
的用法示例。
在下文中一共展示了Timer.schedule方法的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: 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);
}
示例4: 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);
}
示例5: SpawnItemThread
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public SpawnItemThread(int numberOfItemFields, Server server)
{
this.itemFields = numberOfItemFields;
this.server = server;
/*--------------INCREASE BOMB RANGE--------------*/
Timer.schedule(new Timer.Task()
{
@Override
public void run()
{
if(cubicRange < Constants.MAXCUBICRANGE)
{
cubicRange += 1;
}
if(normalRange < Constants.MAXBOMBRANGE)
{
normalRange += 1;
}
}
}
,60 // first execute delay
,60 // delay between executes
);
}
示例6: Transfer
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
/********************************************
* Triggle Event
*************************************/
public void Transfer(final String mapName, final Vector2 pos, final Role.Direction dir) {
float delay = 0.1000f; // seconds
player.setVisible(false);
Timer.schedule(new Timer.Task() {
@Override
public void run() {
mapMgr.loadMap(mapName);
player.setCurrentDir(dir);
player.setPosInMap(pos);
player.setVisible(true);
fighting = 0;
cycleTime = 0;
}
}, delay);
}
示例7: tap
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public Integer tap() {
if (currentClearTask != null) {
currentClearTask.cancel();
}
currentClearTask = Timer.schedule(clearTask, clearInterval);
if (tapTimes.size() == numberOfTaps) {
tapTimes.remove(0);
}
tapTimes.add(TimeUtils.nanoTime());
long sum = 0;
if (tapTimes.size() > 1) {
for (int i = 1; i < tapTimes.size(); i++) {
sum += tapTimes.get(i) - tapTimes.get(i - 1);
}
float averageSeconds = sum / (tapTimes.size() - 1) / 1000000000f;
int bpm = (int) (60f / averageSeconds);
return bpm;
} else {
return null;
}
}
示例8: loadComplete
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void loadComplete() {
// System.out.print("[");
// for (Block b : blocks) {
// System.out.print("[\"" + b.body.getPosition().x + "\"d \"" + b.body.getPosition().y + "\"d]");
// }
// System.out.println("]");
//// System.out.print("[");
//// for (Entity b : entities) {
//// System.out.print("[\"" + b.body.getPosition().x + "\"d \"" + b.body.getPosition().y + "\"d]");
//// }
//// System.out.println("]");
Timer.schedule(new Task() {
public void run() {
loaded = true;
}
}, 1);
}
示例9: playerAttacks
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void playerAttacks(Role player){
if( _currentOpponent == null ){
return;
}
//Check for magic if used in attack; If we don't have enough MP, then return
// int mpVal = ProfileManager.getInstance().getProperty("currentPlayerMP", Integer.class);
int mpVal = player.getMagicPoint();
battleUI.updateEvent(_currentOpponent, BattleEvent.PLAYER_TURN_START);
if( _currentPlayerWandAPPoints == 0 ){
if( !_playerAttackCalculations.isScheduled() ){
Timer.schedule(_playerAttackCalculations, 1);
}
}else if(_currentPlayerWandAPPoints > mpVal ){
BattleState.this.battleUI.updateEvent(_currentOpponent, BattleEvent.PLAYER_TURN_DONE);
return;
}else{
if( !_checkPlayerMagicUse.isScheduled() && !_playerAttackCalculations.isScheduled() ){
Timer.schedule(_checkPlayerMagicUse, .5f);
Timer.schedule(_playerAttackCalculations, 1);
}
}
}
示例10: create
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void create() {
batch = new SpriteBatch();
sr = new ShapeRenderer();
bg[0] = new Sprite(new Texture(Gdx.files.internal("gfx/loadingscreens/layout.png")));
bg[1] = new Sprite(new Texture(Gdx.files.internal("gfx/loadingscreens/layout-dif.png")));
fps = new Button("Fps: " + 60, 32, 678);
Timer.schedule(new Timer.Task() {
@Override
public void run() {
fps.text = "Fps: " + (int) (1 / Gdx.graphics.getDeltaTime());
}
}, 1f, 1f);
}
示例11: handleMessage
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
@Override
public boolean handleMessage (Telegram msg) {
TelegramMessage telegramMsg = TelegramMessage.values()[msg.message];
switch (telegramMsg) {
case SQUAD_INPUT_SELECTED:
int index = (Integer)msg.extraInfo;
setSelected(index, true);
return true;
case GUI_INSUFFICIENT_RESOURCES:
if(resourceAlertTask.isScheduled())
resourceAlertTask.cancel();
Timer.schedule(resourceAlertTask, 0.0f, 0.15f, 5);
return true;
default:
return false;
}
}
示例12: encryptGameTitle
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
private void encryptGameTitle() {
char oldCharTmp;
int indexTmp;
do {
indexTmp = (int)(Math.random() * gameTitle.getText().length());
oldCharTmp = gameTitle.getText().charAt(indexTmp);
} while (!Character.isLetter(oldCharTmp) || oldCharTmp == 'M');
final char oldChar = oldCharTmp;
final int index = indexTmp;
int number = (int)(Math.random() * 10);
gameTitle.setText(gameTitle.getText().substring(0, index) + number + gameTitle.getText().substring(index + 1));
Timer.schedule(new Timer.Task() {
@Override
public void run() {
gameTitle.setText(gameTitle.getText().substring(0, index) + oldChar + gameTitle.getText().substring(index + 1));
}
}, ENCRYPTION_DURATION);
}
示例13: show
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void show() {
splash0 = new Timer.Task(){
public void run() {
stage = 1;
Timer.schedule(splash1, 1.5F);
loadAssets();
}
};
splash1 = new Timer.Task(){
public void run() {
NerdShooter.shooter.setScreen(new StartScreen());
}
};
Timer.schedule(splash0, 1.5F);
}
示例14: RespawnEnemy
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void RespawnEnemy() {
Timer.schedule(new Task(){
@Override
public void run() {
tics++;
if(tics > 25){
tics = 1;
}
if (tics == 1) {enemigoSpamea = true;}
if (tics == 2) {enemigoSpamea = true;}
if (tics == 3) {enemigoSpamea = true;}
if (tics == 5) {enemigoSpamea = false;}
if(tics % 2 == 0) {go=1;} else {go=0;}
}
}
,0,30/30.0f);
}
示例15: animacionGameOver
import com.badlogic.gdx.utils.Timer; //導入方法依賴的package包/類
public void animacionGameOver() {
Timer.schedule(new Task(){
@Override
public void run() {
tics++;
if(tics > 60){
tics = 0;
}
if(tics%10==0){if(timer>0 && Juego.gameOver==0 && Juego.titleScreen==0){timer--;}}
if(tics==20 && Juego.gameOver==1){Juego.titleScreen=1;}
if(tics==20){Juego.gameOver=0;}
}
}
,0,30/35.0f);
}