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


Java TimeUtils类代码示例

本文整理汇总了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);
}
 
开发者ID:ja-brouil,项目名称:StarshipFighters,代码行数:22,代码来源:IntroState.java

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

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

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

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

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

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

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

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

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

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

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

示例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;
  }
}
 
开发者ID:odedw,项目名称:TempoGDX,代码行数:26,代码来源:TapTempoCalculator.java

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

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

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


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