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


Java TimeUtils.timeSinceMillis方法代码示例

本文整理汇总了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();

}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:29,代码来源:SaveData.java

示例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);
    }
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:19,代码来源:AnimatedTile.java

示例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--;
    }
}
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:17,代码来源:Bird.java

示例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();
}
 
开发者ID:udacity,项目名称:ud405,代码行数:19,代码来源:OrthographicCameraExercise.java

示例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();
}
 
开发者ID:udacity,项目名称:ud405,代码行数:19,代码来源:OrthographicCameraExercise.java

示例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);
	}
	
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:11,代码来源:IntroState.java

示例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();

	}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:32,代码来源:BasicAlien.java

示例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();
		}
	}
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:33,代码来源:SamusShipBoss.java

示例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;
	}
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:36,代码来源:SamusShipBoss.java

示例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;
		}
	}
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:15,代码来源:SamusShipBoss.java

示例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);
	}

}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:11,代码来源:SamusShipBoss.java

示例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;
}
 
开发者ID:Entwicklerpages,项目名称:school-game,代码行数:35,代码来源:Player.java

示例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();
                }
            }
        }
    }
}
 
开发者ID:B4sileus,项目名称:guitar-finger-trainer,代码行数:40,代码来源:TrainingScreen.java

示例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;
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:19,代码来源:UIObject.java

示例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();
}
 
开发者ID:Xemiru,项目名称:Undertailor,代码行数:13,代码来源:PressData.java


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