本文整理汇总了Java中com.badlogic.gdx.utils.TimeUtils.nanoTime方法的典型用法代码示例。如果您正苦于以下问题:Java TimeUtils.nanoTime方法的具体用法?Java TimeUtils.nanoTime怎么用?Java TimeUtils.nanoTime使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.badlogic.gdx.utils.TimeUtils
的用法示例。
在下文中一共展示了TimeUtils.nanoTime方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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();
}
示例2: 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();
}
}
示例3: spawnPolitico
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void spawnPolitico() {
float x = 0;
float y = MathUtils.random(100, 600 - 64); ;
int numero = MathUtils.random(0,100);
if(numero>0 && numero<5){
numeroTemplate = 0;
}
if(numero>5 && numero<25){
numeroTemplate = 1;
}
if(numero>25 && numero<55){
numeroTemplate = 2;
}
if(numero>55 && numero<85){
numeroTemplate = 3;
}
if(numero>85 && numero<100){
numeroTemplate = 4;
}
int temp = numeroTemplate;
PoliticoTemplate t = politicoTemplate.get(temp);
Politico politico = new Politico(t.getTextura(),t.getPuntaje(),t.getVelocidad(),x,y);
politicos.add(politico);
lastDropTime = TimeUtils.nanoTime();
}
示例4: diceRoll
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/**
* Roll all dice and update their results
*/
private void diceRoll() {
Random rnd = new Random(TimeUtils.nanoTime());
// generate a random number from 1-6
for (int i = 0; i < data.getAvailableDice(); i++) {
rollResults[i] = rnd.nextInt(6) + 1;
}
}
示例5: PlayState
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public PlayState(GameStateManager gsm) {
super(gsm);
score = 0;
chapa = new Chapa(50, 300);
camera.setToOrtho(false, FlappyChapa.WIDTH / 2, FlappyChapa.HEIGHT / 2);
Texture texture = new Texture("bg.png");
backGround = new org.academiadecodigo.bootcamp.sprites.Background(camera);
backGround.start();
ground = new Texture("ground.png");
/*table = new Table();
table.setPosition(camera.position.x,camera.position.y);
//table.setBounds(camera.position.x,camera.position.y,camera.viewportWidth,camera.viewportHeight/10);
table.setFillParent(true);*/
scoreLabel = new Label(String.format("%06d", score), new Label.LabelStyle(new BitmapFont(), Color.WHITE));
scoreLabel.setPosition(camera.position.x,0);
startTime = TimeUtils.nanoTime();
anto = new Anto(camera);
// groundPos1 = new Vector2(camera.position.x - camera.viewportWidth / 2, GROUND_Y_OFFSET);
// groundPos2 = new Vector2((camera.position.x - camera.viewportWidth / 2) + ground.getWidth(), GROUND_Y_OFFSET);
tubes = new Array<Tube>();
for (int i = 0; i < TUBE_COUNT; i++) {
tubes.add(new Tube(i * (TUBE_SPACING + Tube.TUBE_WIDTH)));
}
music = Gdx.audio.newMusic(Gdx.files.internal("bigSmoke_justAudio.mp3"));
music.setLooping(true);
music.setVolume(0.5f);
music.play();
}
示例6: TimeScorer
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public TimeScorer(final Klooni game, GameLayout layout) {
super(game, layout, Klooni.getMaxTimeScore());
highScore = Klooni.getMaxTimeScore();
Label.LabelStyle labelStyle = new Label.LabelStyle();
labelStyle.font = game.skin.getFont("font");
timeLeftLabel = new Label("", labelStyle);
timeLeftLabel.setAlignment(Align.center);
layout.updateTimeLeftLabel(timeLeftLabel);
startTime = TimeUtils.nanoTime();
deadTime = startTime + START_TIME;
pausedTimeLeft = -1;
}
示例7: resume
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void resume() {
if (pauseTime != 0L) {
long difference = TimeUtils.nanoTime() - pauseTime;
startTime += difference;
deadTime += difference;
pauseTime = 0L;
pausedTimeLeft = -1;
}
}
示例8: GameScreen
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public GameScreen(TheFreeBirdGame game){
this.game = game;
this.bird = game.level.bird;
viewportClose = game.viewportClose;
bird.nanotimeAnimationStart = TimeUtils.nanoTime();
}
示例9: startFlyUp
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void startFlyUp(){
if (energy > 1) { // 1 is for checking should the bird continue living
flyingUp = true;
flying = true;
nanotimeAnimationStart = TimeUtils.nanoTime();
}
}
示例10: touchUp
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
public void touchUp(final InputEvent event, final float x, final float y, int pointer, int button) {
if (pointer == pressedPointer) {
if (!cancelled) {
boolean touchUpOver = isOver(event.getListenerActor(), x, y);
// Ignore touch up if the wrong mouse button.
if (touchUpOver && pointer == 0 && this.button != -1 && button != this.button) touchUpOver = false;
if (touchUpOver) {
long time = TimeUtils.nanoTime();
if (time - lastTapTime > tapCountInterval) tapCount = 0;
tapCount++;
lastTapTime = time;
if (tapCount > 1) {
doubleClicked(event, x, y);
doubleClicked.set(true);
} else {
//wait for double click?
new Timer().schedule(new TimerTask() {
@Override
public void run() {
if (doubleClicked.get()) {
doubleClicked.set(false);
} else {
clicked(event, x, y);
}
}
}, 200);
}
}
}
pressed = false;
pressedPointer = -1;
pressedButton = -1;
cancelled = false;
}
}
示例11: run
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
/** Executes scheduled tasks based on their frequency and phase. This method must be called once per frame.
* @param timeToRun the maximum time in nanoseconds this scheduler should run on the current frame. */
@Override
public void run (long timeToRun) {
// Increment the frame number
frame++;
// Clear the list of tasks to run
runList.size = 0;
// Go through each task
for (int i = 0; i < schedulableRecords.size; i++) {
SchedulableRecord record = schedulableRecords.get(i);
// If it is due, schedule it
if ((frame + record.phase) % record.frequency == 0) runList.add(record);
}
// Keep track of the current time
long lastTime = TimeUtils.nanoTime();
// Find the number of tasks we need to run
int numToRun = runList.size;
// Go through the tasks to run
for (int i = 0; i < numToRun; i++) {
// Find the available time
long currentTime = TimeUtils.nanoTime();
timeToRun -= currentTime - lastTime;
long availableTime = timeToRun / (numToRun - i);
// Run the schedulable object
runList.get(i).schedulable.run(availableTime);
// Store the current time
lastTime = currentTime;
}
}
示例12: moveRight
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void moveRight(float delta) {
if (jumpState == JumpState.GROUNDED && walkState != WalkState.WALKING) {
walkStartTime = TimeUtils.nanoTime();
}
walkState = WalkState.WALKING;
facing = Facing.RIGHT;
position.x += delta * Constants.GIGAGAL_MOVE_SPEED;
}
示例13: continueJump
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void continueJump() {
if (jumpState == JumpState.JUMPING) {
float jumpDuration = MathUtils.nanoToSec * (TimeUtils.nanoTime() - jumpStartTime);
if (jumpDuration < Constants.MAX_JUMP_DURATION) {
velocity.y = Constants.JUMP_SPEED;
} else {
endJump();
}
}
}
示例14: create
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
@Override
public void create() {
renderer = new ShapeRenderer();
viewport = new ExtendViewport(WORLD_SIZE, WORLD_SIZE);
// TODO: Save current value of TimeUtils.nanoTime()
startTime = TimeUtils.nanoTime();
}
示例15: moveLeft
import com.badlogic.gdx.utils.TimeUtils; //导入方法依赖的package包/类
private void moveLeft(float delta) {
if (jumpState == JumpState.GROUNDED && walkState != WalkState.WALKING) {
walkStartTime = TimeUtils.nanoTime();
}
walkState = WalkState.WALKING;
facing = Facing.LEFT;
position.x -= delta * Constants.GIGAGAL_MOVE_SPEED;
}