本文整理汇总了Java中com.badlogic.gdx.utils.TimeUtils.timeSinceMillis方法的典型用法代码示例。如果您正苦于以下问题:Java TimeUtils.timeSinceMillis方法的具体用法?Java TimeUtils.timeSinceMillis怎么用?Java TimeUtils.timeSinceMillis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.TimeUtils
的用法示例。
在下文中一共展示了TimeUtils.timeSinceMillis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: save
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/**
* Speichert die Daten in die Spieldatei.
*
* @param slot der Slot in den gespeichert werden soll. Wenn null, wird der letzte Slot verwendet
*
* @see SaveData#load()
*/
public void save(Slot slot)
{
if (slot == null)
slot = this.slot;
else
this.slot = slot;
if (this.slot == null) return;
playTime += TimeUtils.timeSinceMillis(startTime);
prefs.putString(slot.name() + PLAYER_NAME, playerName);
prefs.putBoolean(slot.name() + MALE, male);
prefs.putLong(slot.name() + PLAY_TIME, playTime);
prefs.putString(slot.name() + LEVEL_NAME, levelName);
prefs.putString(slot.name() + LEVEL_ID, levelId);
prefs.flush();
startTime = TimeUtils.millis();
}
示例2: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render(float x, float y) {
long runtime = TimeUtils.timeSinceMillis(AnimatedTile.origin) % length;
long duration = 0;
Sprite frame = null;
for (int i = 0; i < this.frames.size; i++) {
Tuple<Long, Sprite> key = this.frames.get(i);
duration += key.getA();
frame = key.getB();
if (duration > runtime) {
break;
}
}
if (frame != null) {
frame.render(x, y);
}
}
示例3: transformFoodToEnergyAndPoop
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void transformFoodToEnergyAndPoop() {
if ((TimeUtils.timeSinceMillis(timeCounterFoodTransform) > BIRD_FOOD_DIGEST_TIME) && (food > 0))
{
if (energy < BIRD_ENERGY_MAX){
energy += BIRD_ENERGY_ADD;
if (energy > BIRD_ENERGY_MAX)
energy = BIRD_ENERGY_MAX;
}
if (poop < BIRD_POOP_MAX)
poop++;
else
dropPoop();
timeCounterFoodTransform = TimeUtils.millis();
food--;
}
}
示例4: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// TODO: Call update() on the camera
// TODO: Set the SceneRenderer's projection matrix equal to the camera's combined matrix
renderer.begin(ShapeType.Filled);
float interval = TimeUtils.timeSinceMillis(timeCreated);
float x = X_CENTER + X_AMPLITUDE * MathUtils.sin(MathUtils.PI2 * interval /PERIOD);
float y = Y_CENTER + Y_AMPLITUDE * MathUtils.sin(2* MathUtils.PI2 * interval / PERIOD);
renderer.circle(x, y, BALL_RADIUS);
renderer.end();
}
示例5: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render() {
Gdx.gl.glClearColor(0, 0, 0, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
// TODO: Call update() on the camera
camera.update();
// TODO: Set the SceneRenderer's projection matrix equal to the camera's combined matrix
renderer.setProjectionMatrix(camera.combined);
renderer.begin(ShapeType.Filled);
float interval = TimeUtils.timeSinceMillis(timeCreated);
float x = X_CENTER + X_AMPLITUDE * MathUtils.sin(MathUtils.PI2 * interval /PERIOD);
float y = Y_CENTER + Y_AMPLITUDE * MathUtils.sin(2* MathUtils.PI2 * interval / PERIOD);
renderer.circle(x, y, BALL_RADIUS);
renderer.end();
}
示例6: update
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void update(float dt) {
// Move Next state after Sega
if (TimeUtils.timeSinceMillis(timer) > 3000) {
gsm.setState(GameStateManager.MENU);
soundManager.removeSound(segaSoundName);
}
}
示例7: update
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public void update(float dt, boolean xWrap, boolean yWrap) {
// Update Movement
x += dx;
y += dy;
collisionBounds.set(x, y, (96f / 3f), 33);
// Movement Limits
moveDownward();
setLimits();
// Wraps
if (xWrap) {
wrapXBound();
}
if (yWrap) {
wrapYBound();
}
// Update Shoot | Don't shoot if out of the screen
if (TimeUtils.timeSinceMillis(bulletCooldown) > randomAttackCooldown && x < Game.WIDTH && x > 0
&& y < Game.HEIGHT && y > 0) {
addEnemyBullets(16, 0);
randomAttackCooldown = MathUtils.random(1000, 2000);
}
// Drop Items
dropItems();
}
示例8: shootBullets
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void shootBullets() {
// Shoot Bullets
// Right Wing
if (!isRightWingDead && rightWingHealth > 0) {
if (TimeUtils.timeSinceMillis(bulletCooldownRight) > randomAttackCooldownRight && x < Game.WIDTH && x > 0
&& y < Game.HEIGHT && y > 0) {
addBossBullets(175, 0);
randomAttackCooldownRight = MathUtils.random(200, 1000);
bulletCooldownRight = TimeUtils.millis();
}
}
// Left Wing
if (!isLeftWingDead && leftWingHealth > 0) {
if (TimeUtils.timeSinceMillis(bulletCooldownLeft) > randomAttackCooldownLeft && x < Game.WIDTH && x > 0
&& y < Game.HEIGHT && y > 0) {
addBossBullets(20, 0);
randomAttackCooldownLeft = MathUtils.random(200, 1000);
bulletCooldownLeft = TimeUtils.millis();
}
}
// Both Wings have died
if (isLeftWingDead && isRightWingDead && getHP() > 0) {
if (TimeUtils.timeSinceMillis(bulletCooldown) > randomAttackCooldown && x < Game.WIDTH && x > 0
&& y < Game.HEIGHT && y > 0) {
addBossBullets(98, 30);
randomAttackCooldown = MathUtils.random(200, 800);
bulletCooldown = TimeUtils.millis();
}
}
}
示例9: checkWingStatus
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void checkWingStatus() {
// Check if Wings are dead
if (rightWingHealth <= 0 && !isRightWingDead) {
if (TimeUtils.timeSinceMillis(rightWingExplosionTimer) > 200 && rightWingExplosionCounter < 10) {
// Add delayed explosions
explosionList.add(new Explosion((x + 148) + MathUtils.random(-48, 48), y, 48, height, playState));
rightWingExplosionTimer = TimeUtils.millis();
rightWingExplosionCounter++;
}
// Kill Right Wing
if (rightWingExplosionCounter == 10) {
setRightWingDead(true);
}
}
if (leftWingHealth <= 0 && !isLeftWingDead) {
if (TimeUtils.timeSinceMillis(leftWingExplosionTimer) > 200 && leftWingExplosionCounter < 10) {
// Add delayed explosions
explosionList.add(new Explosion(x + MathUtils.random(-48, 48), y, 48, height, playState));
leftWingExplosionTimer = TimeUtils.millis();
leftWingExplosionCounter++;
}
// Kill Left Wing
if (leftWingExplosionCounter == 10) {
setLeftWingDead(true);
}
}
// If Both wings are dead, then set middle to be vulnerable
if (isLeftWingDead && isRightWingDead && isMiddleInvincible) {
isMiddleInvincible = false;
}
}
示例10: checkMiddleHP
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void checkMiddleHP() {
if (healthbar < 0) {
dx = 0;
dy = 0;
if (TimeUtils.timeSinceMillis(bossDeathExplosionTimer) > 200 && bossDeathExplosionCounter < 15) {
// Add delayed explosions
explosionList.add(new Explosion(x + (0.5f * MathUtils.random(0, width)),
(y + (0.5f * MathUtils.random(0, height))), width, height, playState));
bossDeathExplosionTimer = TimeUtils.millis();
bossDeathExplosionCounter++;
isDead = true;
}
}
}
示例11: spawnEnemies
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void spawnEnemies() {
// Check if its been 5 seconds
if (TimeUtils.timeSinceMillis(timeSinceBattleBegan) > 5000 && healthbar > 0) {
listOfAliens.add(new BasicAlien(x + (width / 2), y + (height / 2), 3, 0, 1000L, -15, enemyBullets, -20, playState));
listOfAliens.add(new BasicAlien(x + (width / 2), y + (height / 2), -3, 0, 1000L, -15, enemyBullets, -20, playState));
timeSinceBattleBegan = TimeUtils.millis();
soundManager.playSound(bossSpawnSoundName, 1f);
}
}
示例12: keyUp
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/**
* Regiert auf das Loslassen einer Taste.
*
* Führt die Attacke nach dem Loslassen der entsprechenden Taste durch.
*
* @param keycode der Tastencode der Taste
* @return true, wenn auf das Ereignis reagiert wurde
*/
public boolean keyUp(int keycode)
{
InputManager.Action action = InputManager.checkGameAction(keycode);
if (action == InputManager.Action.ATTACK && attackStart > 0)
{
// Attacke
if (attackCallback == null)
return false;
long attackTime = TimeUtils.timeSinceMillis(attackStart);
if (attackTime >= LONG_ATTACK_TIME)
{
attackCallback.run((int)(attackTime/400));
attackSword = 0.4f;
} else {
attackCallback.run(1);
attackSword = 0.2f;
}
attackStart = -1;
return true;
}
return false;
}
示例13: applyRules
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void applyRules() {
if (SettingsUtil.playEnabled) {
if (this.firstRun > 0) {
if (TimeUtils.timeSinceMillis(this.lastUpdateTime) >= 1000) {
AssetsUtil.playSound(AssetsUtil.clickSound);
this.firstRun--;
this.lastUpdateTime = TimeUtils.millis();
}
} else if (TimeUtils.timeSinceMillis(this.lastUpdateTime) >= this.bpm) {
AssetsUtil.playSound(AssetsUtil.clickSound);
this.lastUpdateTime = TimeUtils.millis();
if (this.grid.forward) {
this.grid.currentPosition++;
} else {
this.grid.currentPosition--;
}
if (this.grid.currentPosition == this.grid.noteSequence.length) {
if (!SettingsUtil.backForwardEnabled) {
this.grid.currentPosition = 0;
if (SettingsUtil.autoMoveToNext) {
this.firstRun = 3;
this.grid.loadNextTraining();
}
} else {
this.grid.currentPosition--;
this.grid.forward = false;
}
} else if (!this.grid.forward && this.grid.currentPosition == 0) {
this.grid.forward = true;
if (SettingsUtil.autoMoveToNext) {
this.firstRun = 3;
this.grid.loadNextTraining();
}
}
}
}
}
示例14: isPastLifetime
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/**
* Returns whether or not this {@link UIObject} is past
* its maximum lifetime, as defined by
* {@link #getMaxLifetime()}.
*
* @return if this UIObject is past its max lifetime
*/
public boolean isPastLifetime() {
if (this.lifetime <= 0) {
return false;
}
if (this.lifestart <= 0) {
return false;
}
return TimeUtils.timeSinceMillis(this.lifestart) > this.lifetime;
}
示例15: up
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/**
* Internal method.
*
* <p>Updates the data of this {@link PressData} in
* response to its assigned key being released.</p>
*/
void up() {
this.isPressed = false;
this.holdTime = TimeUtils.timeSinceMillis(this.holdTime);
this.lastReleaseTick = parent.currentTick + 1;
this.lastReleaseTime = TimeUtils.millis();
}