本文整理汇总了Java中com.badlogic.gdx.utils.TimeUtils.millis方法的典型用法代码示例。如果您正苦于以下问题:Java TimeUtils.millis方法的具体用法?Java TimeUtils.millis怎么用?Java TimeUtils.millis使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.TimeUtils
的用法示例。
在下文中一共展示了TimeUtils.millis方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TrainingScreen
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
TrainingScreen(GftGame game) {
this.game = game;
this.guiCam = new OrthographicCamera(800, 480);
this.guiCam.position.set(800 / 2, 480 / 2, 0);
this.backBounds = new Rectangle(7, 432, 48, 48);
this.playPauseBounds = new Rectangle(7, 7, 48, 48);
this.restartBounds = new Rectangle(62, 7, 48, 48);
this.backFowardtBounds = new Rectangle(127, 7, 48, 48);
this.soundBounds = new Rectangle(192, 7, 48, 48);
this.minusBounds = new Rectangle(590, 7, 48, 48);
this.plusBounds = new Rectangle(699, 7, 48, 48);
this.touchPoint = new Vector3();
this.grid = new Grid(this.game);
this.grid.loadTraining();
this.bottomBar = new BottomBar(this.game);
this.firstRun = 3;
this.lastUpdateTime = TimeUtils.millis();
this.bpm = MINUTE_IN_MILLIS / SettingsUtil.bpm;
}
示例2: init
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void init() {
// Start Shooting
bulletCooldown = TimeUtils.millis();
enemyBulletSpeed = 5;
randomAttackCooldown = MathUtils.random(200, 1000);
// Drop Chance | 10% chance
dropChance = MathUtils.random(0, 9);
// Start Sprites
allTexture = new Texture(Gdx.files.internal(pathName));
TextureRegion[][] tmp = TextureRegion.split(allTexture, allTexture.getWidth() / 3, allTexture.getHeight() / 1);
rolls = new TextureRegion[3];
for (int i = 0; i < rolls.length; i++) {
rolls[i] = tmp[0][i];
}
// Start rectangle
collisionBounds = new Rectangle(x, y, allTexture.getWidth() / 3, allTexture.getHeight());
}
示例3: 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();
}
示例4: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render(float delta) {
Gdx.gl.glClearColor(0.845f, 0.845f, 0.845f, 1);
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
game.batch.begin();
game.batch.draw(appLogo, viewport.getWorldWidth()/2 - 60, viewport.getWorldHeight()/2 - 60, 120, 120);
Color color = game.batch.getColor();
color.a = 0.4f;
game.batch.setColor(color);
game.batch.draw(samukiLogo, viewport.getWorldWidth()/2-32, 32, 64, 64);
game.batch.draw(updateText, viewport.getWorldWidth()/2-198, viewport.getWorldHeight()-100, 396, 42);
color.a = 1f;
game.batch.setColor(color);
game.batch.end();
if (TimeUtils.millis()>(startTime+1250))
game.setScreen(new MenuScreen(game));
stage.act(Math.min(Gdx.graphics.getDeltaTime(), 1/30f));
stage.draw();
}
示例5: 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--;
}
}
示例6: Cat
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public Cat(ShapeRenderer renderer, Boolean facingRight) {
super(renderer, new Vector2(), facingRight);
if (facingRight) {
position.set(CAT_START_X_LEFT, CAT_Y);
velocity.set(CAT_SPEED_X, 0f);
}
else{
position.set(CAT_START_X_RIGHT, CAT_Y);
velocity.set(-CAT_SPEED_X, 0f);
}
catCreateMillis = TimeUtils.millis();
circle = new Circle(0,0, CAT_HEAD_RADIUS);
rectangle = new Rectangle(0,0, CAT_BODY_LENGTH, CAT_BODY_WIDTH);
update(0);
}
示例7: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render(float delta) {
double newTime = TimeUtils.millis() / 1000.0;
double frameTime = Math.min(newTime - currentTime, Env.MAX_STEP);
float deltaTime = (float)frameTime;
currentTime = newTime;
accumulator += frameTime;
while (accumulator >= Env.STEP) {
engine.getSystem(PhysicsSystem.class).setAlpha(Env.STEP / (float)accumulator);
engine.update(deltaTime);
accumulator -= Env.STEP;
}
engine.getSystem(RenderingSystem.class).update(Env.STEP);
}
示例8: loadModelList
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public void loadModelList()
{
File file = Gdx.files.internal("assets/objects.json").file();
try
{
ModelDesc[] list = _gson.fromJson(new FileReader(file), ModelDesc[].class);
for (ModelDesc item : list)
{
item._lastUsage = TimeUtils.millis();
_modelList.put(item._typeId, item);
}
}
catch (FileNotFoundException e)
{
_log.error("objects config not found", e);
System.exit(-1);
}
}
示例9: render
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void render(float delta) {
// set hasBeenShaken to true once hasShaken() registered, so the if statement
// continues to the animation/result even if device isn't moving anymore
if ((hasShaken() || hasBeenShaken) && canRoll) {
// only update if it hasn't been shaken in the last 2 seconds
if (TimeUtils.millis() - lastShakeTime > 5000) {
diceRoll();
lastShakeTime = TimeUtils.millis();
hasBeenShaken = true;
}
// randomize results for 2 seconds after a shake
if (TimeUtils.millis() - lastShakeTime < 2000) {
randomizeDice();
} else {
showRollResult();
hasBeenShaken = false;
canRoll = false;
}
}
super.render(delta);
}
示例10: draw
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void draw(Batch batch, float parentAlpha) {
long now = TimeUtils.millis();
if (now > nextTextUpdate) {
interpolateText();
nextTextUpdate = TimeUtils.millis() + SHOW_ONE_CHARACTER_EVERY;
if (now > nextTempRevertUpdate && showingTemp) {
// We won't be showing temp anymore if the current money is shown
showCurrentMoney();
}
}
setColor(Klooni.theme.bandColor);
infoLabel.setColor(Klooni.theme.textColor);
super.draw(batch, parentAlpha);
}
示例11: init
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void init() {
// Start Game Objects
shipBullets = new Array<PlayerBullets>();
enemyBulletList = new Array<EnemyBullets>();
player = new Player(300, 150, 0, 0, shipBullets, this);
basicAliens = new Array<GameObjects>();
explosionList = new Array<Explosion>();
itemList = new Array<Item>();
collisionHandling = new CollisionHandling(this);
// Start Level
levelLoader = new Level("data/levels/testmap.tmx", this);
for (int i = 0; i < levelLoader.getEnemyArray().size; i++) {
basicAliens.add(new BasicAlien(levelLoader.getEnemyArray().get(i).x, levelLoader.getEnemyArray().get(i).y, 0, -5, 1000L, -15, getEnemyBulletList(), -20, this));
}
// Start the HUD
// 0 = Health Bar
allHUDElements = new HUD[1];
allHUDElements[0] = new HealthBar(10, 760, 200, 25, true);
// Timers
deathTimer = TimeUtils.millis();
// Audio
soundManager = getGSM().getGame().getSoundManager();
musicManager = getGSM().getGame().getMusicManager();
}
示例12: Level1
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public Level1(Array<GameObjects> enemyList, int levelNumber, PlayState playState) {
super(enemyList, playState.getExplosionList(), playState.getEnemyBulletList(), levelNumber, playState);
// Get lists
this.enemyList = enemyList;
this.levelNumber = levelNumber;
this.playState = playState;
// Start Background
initializeBackground();
// Update Timer
timeSinceLevelBegan = TimeUtils.millis();
waveTimer = TimeUtils.millis();
// Initialize the switches
gameplaySwitch = new boolean[20];
for (int i = 0; i < gameplaySwitch.length; i++) {
gameplaySwitch[i] = false;
}
gameplaySwitch[0] = true;
switchCounter = 0;
// Start Music
startMusic();
}
示例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: Player
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public Player(float x, float y, float dx, float dy, Array<PlayerBullets> listOfBullets, PlayState playState) {
super(x, y, dx, dy);
// GamePlay
this.x = x;
this.y = y;
this.dx = dx;
this.dy = dy;
this.listOfBullets = listOfBullets;
this.playState = playState;
bulletcooldown = TimeUtils.millis();
// Graphics
pathname = "data/spaceships/ship1.png";
animationFrameDuration = 1f/40f;
// SFX
this.playState = playState;
soundManager = playState.getGSM().getGame().getSoundManager();
bulletShotSoundPathName = "data/audio/sound/Basic Shot.wav";
bulletShotSoundName = "Shoot1";
// Limits
maxSpeed = 4;
//friction = 5;
minimumSpeed = -4;
bulletSpeed = 15;
bulletShootSpeed = 200;
// Start Player Loading
init();
}
示例15: 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();
}
}
}