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


Java TimeUtils.nanoTime方法代码示例

本文整理汇总了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();
}
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:23,代码来源:Caterpillar.java

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

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

示例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;
    }
}
 
开发者ID:cpppwner,项目名称:NoRiskNoFun,代码行数:12,代码来源:DiceRollScene.java

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

示例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;
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:16,代码来源:TimeScorer.java

示例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;
    }
}
 
开发者ID:LonamiWebs,项目名称:Klooni1010,代码行数:12,代码来源:TimeScorer.java

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

}
 
开发者ID:andrkhar,项目名称:TheFreeBird,代码行数:8,代码来源:GameScreen.java

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

示例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;
    }
}
 
开发者ID:Longri,项目名称:cachebox3.0,代码行数:36,代码来源:DoubleClickListener.java

示例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;
	}
}
 
开发者ID:Mignet,项目名称:Inspiration,代码行数:38,代码来源:LoadBalancingScheduler.java

示例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;
}
 
开发者ID:udacity,项目名称:ud406,代码行数:9,代码来源:GigaGal.java

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

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

示例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;
}
 
开发者ID:udacity,项目名称:ud406,代码行数:9,代码来源:GigaGal.java


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