当前位置: 首页>>代码示例>>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;未经允许,请勿转载。