本文整理汇总了Java中com.badlogic.gdx.utils.TimeUtils类的典型用法代码示例。如果您正苦于以下问题:Java TimeUtils类的具体用法?Java TimeUtils怎么用?Java TimeUtils使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TimeUtils类属于com.badlogic.gdx.utils包,在下文中一共展示了TimeUtils类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
@Override
public void init() {
// Timer
timer = TimeUtils.millis();
// Strings
segaPathname = "data/audio/sound/Sega.wav";
segaSoundName = "Sega Sound";
segaLogoPathName = "data/background/segalogo.png";
// Start Sound
soundManager = gsm.getGame().getSoundManager();
soundManager.addSound(segaPathname, segaSoundName);
// Texture
texture = new Texture(Gdx.files.internal(segaLogoPathName));
// Play Sound
soundManager.playSound(segaSoundName, 1.0f);
}
示例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: 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;
}
示例5: 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();
}
示例6: 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);
}
}
示例7: recalculateDinamicFlyingPoints
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
public void recalculateDinamicFlyingPoints(){
float wingY;
if (isGlyding())
wingY = wingLT.y;
else {
float dinamicValue = (wingLT.y - wingLB.y) * (1.3f*MathUtils.cos(MathUtils.PI2 * TimeUtils.timeSinceNanos(nanotimeAnimationStart) / BIRD_NANOTIME_FRAME));
wingY = wingLB.y - dinamicValue;
}
wingLB.set(wingLT).add(-0.5f * BIRD_SCALE, -2.2f * BIRD_SCALE);
wingRB.set(wingRT).add(0.5f * BIRD_SCALE, -2.2f * BIRD_SCALE);
wingLL.set(wingLT.x - 6f * BIRD_SCALE, wingY);
wingRR.set(wingRT.x + 6f * BIRD_SCALE, wingY);
tailL.set(position.x - 3f * BIRD_SCALE, position.y + 5.5f * BIRD_SCALE);
tailR.set(position.x + 3f * BIRD_SCALE, position.y + 5.5f * BIRD_SCALE);
}
示例8: 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--;
}
}
示例9: Caterpillar
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
public Caterpillar(ShapeRenderer renderer, Vector2 position,boolean facingRight) {
super(renderer, position, facingRight);
float x = position.x - 4 *CATERPILLAR_TIGHT_RADIUS;
float y = position.y;
circles = new Array<Circle>();
for ( int i = 0 ; i< CATERPILLAR_CIRCLES_NUMBER; i++) {
circles.add(new Circle(x, y, CATERPILLAR_RADIUS));
x += 2 * CATERPILLAR_TIGHT_RADIUS;
}
if (facingRight) {
velocity.set(CATERPILLAR_SPEED_X, 0f);
}
else{
velocity.set(-CATERPILLAR_SPEED_X, 0f);
}
nanotimeAnimationStart = TimeUtils.nanoTime();
eye = new Vector2();
}
示例10: updateCircles
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
public void updateCircles(){
float x = position.x - 4 *CATERPILLAR_TIGHT_RADIUS;
float ydelta = CATERPILLAR_Y_DELTA *
MathUtils.cos(MathUtils.PI2 *
TimeUtils.timeSinceNanos(nanotimeAnimationStart)/CATERPILLAR_NANOTIME_FRAME);
float y = position.y + ydelta;
for ( int i = 0 ; i< CATERPILLAR_CIRCLES_NUMBER; i++) {
circles.get(i).setPosition(x, y);
x += 2 * CATERPILLAR_TIGHT_RADIUS;
ydelta = - ydelta;
y = position.y + ydelta;
}
}
示例11: 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);
}
示例12: tap
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的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;
}
}
示例13: run
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
@Override
public void run (long timeToRun) {
// Keep track of the current time
requestControl.lastTime = TimeUtils.nanoTime();
requestControl.timeToRun = timeToRun;
requestControl.timeTolerance = TIME_TOLERANCE;
requestControl.pathFinder = pathFinder;
requestControl.server = this;
// If no search in progress, take the next from the queue
if (currentRequest == null) currentRequest = requestQueue.read();
while (currentRequest != null) {
boolean finished = requestControl.execute(currentRequest);
if (!finished) return;
// Read next request from the queue
currentRequest = requestQueue.read();
}
}
示例14: 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);
}
}
示例15: update
import com.badlogic.gdx.utils.TimeUtils; //导入依赖的package包/类
public void update(float delta, Viewport viewport) {
float secondsSinceLastKick = MathUtils.nanoToSec * (TimeUtils.nanoTime() - lastKick);
if (secondsSinceLastKick > KICK_INTERVAL) {
lastKick = TimeUtils.nanoTime();
randomKick();
}
// Drag is proportional to the current velocity
velocity.x -= delta * DRAG * velocity.x;
velocity.y -= delta * DRAG * velocity.y;
position.x += delta * velocity.x;
position.y += delta * velocity.y;
radius = RADIUS_FACTOR * Math.min(viewport.getWorldWidth(), viewport.getWorldHeight());
collideWithWalls(radius, viewport.getWorldWidth(), viewport.getWorldHeight());
}