當前位置: 首頁>>代碼示例>>Java>>正文


Java Timer類代碼示例

本文整理匯總了Java中com.badlogic.gdx.utils.Timer的典型用法代碼示例。如果您正苦於以下問題:Java Timer類的具體用法?Java Timer怎麽用?Java Timer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Timer類屬於com.badlogic.gdx.utils包,在下文中一共展示了Timer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: sendOpenSessionEvent

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
protected void sendOpenSessionEvent() {
    if (!isSessionActive())
        return;

    Map<String, String> params = new HashMap<String, String>();
    addGameIDUserNameUserToken(params);

    final Net.HttpRequest http = buildJsonRequest("sessions/open/", params);

    if (http != null)
        Gdx.net.sendHttpRequest(http, new NoOpResponseListener());

    pingTask = Timer.schedule(new Timer.Task() {
        @Override
        public void run() {
            sendKeepSessionOpenEvent();
        }
    }, GJ_PING_INTERVAL, GJ_PING_INTERVAL);

}
 
開發者ID:MrStahlfelge,項目名稱:gdx-gamesvcs,代碼行數:21,代碼來源:GameJoltClient.java

示例2: create

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void create()
{
    enemyStack = new Stack<Enemy>();


    Timer.schedule(new Task()
    {
        @Override
        public void run()
        {
            int choiceToMove = MathUtils.random(3);
            for(int i = 0; i < 5; i++)
            {
                enemyStack.add(new WeakEnemy(choiceToMove, xOffset * i, yOffset * i));
            }
            //Timer.instance().clear();
        }
    }, 0.5f, intervalBetweenSpawn);
}
 
開發者ID:UdealInferno,項目名稱:Parasites-of-HellSpace,代碼行數:20,代碼來源:SpawningEnemy.java

示例3: downenergy

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void downenergy(int value){
    bar.act(Gdx.graphics.getDeltaTime());
    infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy() - value);
    FadeIn();
    new Timer().schedule(new Timer.Task() {
        @Override
        public void run() {
            bar.setAnimateDuration(3);
            bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            mapsScreen.startTimer();
        }
    }, 1000);
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:19,代碼來源:ProgressBarEnergy.java

示例4: update

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void update() {
    bar.act(Gdx.graphics.getDeltaTime());
    infoProfile.getDateUserGame().setEnergy(infoProfile.getDateUserGame().getEnergy());
    username.setText("L "+infoProfile.getDateUserGame().getLevel()+" "+infoProfile.getDateUser().getFristName());
    bar.setValue(infoProfile.getDateUserGame().getEnergy() - infoProfile.getValueenergyuse());
    FadeIn();
    new Timer().schedule(new Timer.Task() {
        @Override
        public void run() {
            bar.setAnimateDuration(3);
            bar.setValue((float) infoProfile.getDateUserGame().getEnergy());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            if(infoProfile.getDateUserGame().getEnklaveCombatId() == -1)
                mapsScreen.startTimer();
        }
    } ,1);
}
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:22,代碼來源:ProgressBarEnergy.java

示例5: screenExit

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void screenExit(String message){
        messageShow = message;
        showtextexit = true;
        circleShow = false;
        InformationProfile.getInstance().getDateUserGame().setEnklaveCombatId(-1);
        Label labelmess = new Label("You already joined this combat once!",new Label.LabelStyle(bitmapFont,Color.WHITE));
        labelmess.setPosition(WIDTH /2 - labelmess.getWidth() /2,labelmess.getHeight()*2);
        stage.addActor(labelmess);
        combatFight.deselect();
        attachers.deselect();
        defenders.deselect();
        if(!message.contentEquals("You lose!")){
            new Timer().scheduleTask(new Timer.Task() {
                @Override
                public void run() {
                    managerAssets.getAssertEnklaveScreen().setIsupdate(false);
                    new GetEnklaveDetails().makeRequest(InformationEnklave.getInstance().getId(), managerAssets);
//                    gameManager.setScreen(gameManager.screenEnklave);
                }
            },1);
        }
    }
 
開發者ID:TudorRosca,項目名稱:enklave,代碼行數:23,代碼來源:ScreenCombat.java

示例6: setUpPlayButton

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setUpPlayButton() {
    playButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "playbtn", false);
    playButton.setPosition(Constants.WIDTH / 4 - playButton.getWidth() * 2 / 5,
            Constants.HEIGHT / 2 - playButton.getHeight() * 2.5f -2);
    playButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            //FlappySpinner.gameManager.hideAd();
            float delay = 0.3f;
            setUpFadeOut();
            Timer.schedule(new Timer.Task() {
                @Override
                public void run() {
                    game.setScreen(new GameScreen(game, 0, false));
                }
            }, delay);
        }
    });
    stage.addActor(playButton);
}
 
開發者ID:ZephyrVentum,項目名稱:FlappySpinner,代碼行數:21,代碼來源:MenuScreen.java

示例7: setUpMarketButton

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setUpMarketButton() {
    marketButton = new GameButton(Constants.RECTANGLE_BUTTON_WIDTH, Constants.RECTANGLE_BUTTON_HEIGHT, "market", false);
    marketButton.setPosition(Constants.WIDTH * 3 / 4 - marketButton.getWidth() * 3 / 5,
            Constants.HEIGHT / 2 - marketButton.getHeight() * 2.5f - 2);
    marketButton.addListener(new ChangeListener() {
        @Override
        public void changed(ChangeEvent event, Actor actor) {
            float delay = 0.3f;
            setUpFadeOut();
            Timer.schedule(new Timer.Task() {
                @Override
                public void run() {
                    game.setScreen(new MarketScreen(game));
                }
            }, delay);
        }
    });
    stage.addActor(marketButton);
}
 
開發者ID:ZephyrVentum,項目名稱:FlappySpinner,代碼行數:20,代碼來源:MenuScreen.java

示例8: setTimersAndTasks

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void setTimersAndTasks()
{
	endTask = new Timer.Task()
	{
		public void run()
		{	
			Gdx.app.log("timer", "Ending game");
			endGameWorld(won());
		}
	};
	
	endClock = new CGCTimer(endTask, endTime, false, "endClock");
	
	respawnTask = new Timer.Task()
	{
		public void run()
		{
			respawnHeight = getPlayerAverageY();
		}
	};
	
	respawnClock = new CGCTimer(respawnTask, CAMERA_DELAY, (int)respawnTime * 60);
	respawnClock.name = "respawnClock";
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:25,代碼來源:CGCWorld.java

示例9: Helicopter

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public Helicopter(CGCWorld theWorld, Animation newLowAnimation, Animation newMidAnimation,
		Animation newHighAnimation, EntityType entityType, Body body)
{
	super(newLowAnimation, newMidAnimation, newHighAnimation, entityType, body);
	gameWorld = theWorld;
	Gdx.app.log("In the pipe", "five by five");
	rotation = 90;
	
	//SoundManager.playSound("helicopter", false);
	
	hoverTask = new Timer.Task() {
		
		public void run() 
		{
			stopped = false;
			returnTrip = true;
			getBody().setLinearVelocity(new Vector2(4,0));
		}
	};
	
	hoverClock = new CGCTimer(hoverTask, hoverTime, false, "hoverClock");
	body.setLinearVelocity(new Vector2(4, 0));
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:24,代碼來源:Helicopter.java

示例10: RookieCop

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public RookieCop(CGCWorld theWorld, CharacterArt art, EntityType pEntityType, Body attachedBody, short pID) {
	super(art, pEntityType, attachedBody, pID);
	gameWorld = theWorld;

	maxGrabStrength = MAX_GRAB_STRENGTH_BASE + Math.round(((float)(Math.random() * 2) - 1.0f) * MAX_GRAB_RANGE);
	currentGrabStrength = maxGrabStrength;
	noGrab = false;
	setCoins(0);

	grabCooldownTask = new Timer.Task()
	{
		public void run()
		{
			currentGrabStrength = maxGrabStrength;
			noGrab = false;
		}
	};

	grabCooldownTimer = new CGCTimer(grabCooldownTask, grabCooldown, false, "grabCooldownTimer");
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:21,代碼來源:RookieCop.java

示例11: Sheriff

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public Sheriff(Animation newLowAnimation, Animation newMidAnimation,
		Animation newHighAnimation, EntityType pEntityType,
		Body attachedBody, Boss bo, float startAlpha)
{
	super(newLowAnimation, newMidAnimation, newHighAnimation, pEntityType,
			attachedBody, startAlpha);
	boss = bo;
	fireTask = new Timer.Task()
	{
		
		public void run()
		{
			fire();
		}
	};
	
	fireTimer = new CGCTimer(fireTask, fireTime, true, "fireTimer");
	
	do
	{
		target = CGCWorld.getPrisoners().random();
	}while(!target.isAlive() || target == null);
	
	TimerManager.addTimer(fireTimer);
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:26,代碼來源:Sheriff.java

示例12: SoundEffect

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public SoundEffect(FileHandle f)
{
	mySound = Gdx.audio.newSound(f);
	playTime = (float)(f.length())/(float)(16384);
	
	playTask = new Timer.Task() {
		
		public void run() 
		{
			if(!looping)
			{
				playing = false;
				paused = false;
			}
		}
	};
	
	playTimer = new CGCTimer(playTask, playTime, looping, "playTimer");
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:20,代碼來源:SoundEffect.java

示例13: setUpTimer

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
private void setUpTimer()
{
	hidePromptTask = new Timer.Task()
	{
		public void run()
		{
			if (yDisplacement < creditsBottom)
			{
				showButtonPrompt = false;
			}
		}
	};
	
	autoScrollTask = new Timer.Task()
	{
		public void run()
		{
			autoScroll = true;
		}
	};
	
	hidePromptTimer = new CGCTimer(hidePromptTask, hidePromptTime, false, "hidePromptTimer");
	autoScrollTimer = new CGCTimer(autoScrollTask, autoScrollTime, false, "autoScrollTimer");
}
 
開發者ID:ChainGangChase,項目名稱:cgc-game,代碼行數:25,代碼來源:Credits.java

示例14: keepAttacking

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void keepAttacking() {
	changeState(Enemy.State.ATTACKING, 1, new GameObject.OnAnimationComplete() {
		@Override public void run(GameObject object) {
			changeState(Enemy.State.STANDING);
		}
	});
	
	context.removeLife();
	if(context.life.isEmpty()) return;
	
	int randomAttack = (int) Math.floor(context.soundsEffectEnemyAttack.size()*Math.random());
	context.soundsEffectEnemyAttack.get(randomAttack).play();
	
	Timer.schedule(new Timer.Task() {
		@Override
		public void run() {
			if(!state.equals(Enemy.State.DYING))
				keepAttacking();
		}
	}, TIME_TO_ATTACK);		
}
 
開發者ID:raphaelbruno,項目名稱:ZombieInvadersVR,代碼行數:22,代碼來源:Enemy.java

示例15: die

import com.badlogic.gdx.utils.Timer; //導入依賴的package包/類
public void die() {
    final Enemy enemy = this;
    enabled = false;
    context.tweenManager.killTarget(this, GameObjectAccessor.XYZ);
    context.tweenManager.killTarget(this, GameObjectAccessor.ROTATION);
    
	changeState(Enemy.State.DYING, 1);
	
	Timer.schedule(new Timer.Task() {
		@Override
		public void run() {
			Vector3 position = enemy.transform.getTranslation(new Vector3());
			enemy.moveToAnimation(position.x, -0.5f, position.z, 2, new GameObject.OnAnimationComplete() {
				@Override public void run(GameObject object) {
					context.instances.remove(enemy);
				}
			});
		}
	}, TIME_TO_ATTACK);		
}
 
開發者ID:raphaelbruno,項目名稱:ZombieInvadersVR,代碼行數:21,代碼來源:Enemy.java


注:本文中的com.badlogic.gdx.utils.Timer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。