Java 类com.badlogic.gdx.utils.Timer.Task 实例源码
项目:Parasites-of-HellSpace
文件:SpawningEnemy.java
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);
}
项目:advio
文件:Level.java
public void loadComplete() {
// System.out.print("[");
// for (Block b : blocks) {
// System.out.print("[\"" + b.body.getPosition().x + "\"d \"" + b.body.getPosition().y + "\"d]");
// }
// System.out.println("]");
//// System.out.print("[");
//// for (Entity b : entities) {
//// System.out.print("[\"" + b.body.getPosition().x + "\"d \"" + b.body.getPosition().y + "\"d]");
//// }
//// System.out.println("]");
Timer.schedule(new Task() {
public void run() {
loaded = true;
}
}, 1);
}
项目:libgdxjam
文件:PlayerBulletContactListener.java
@Override
public void beginContact(Contact contact) {
Entity entity = getEntity(contact, PlayerComponent.class);
spawnSmoke(entity);
laserHit.play();
engine.removeEntity(entity);
Timer.instance().scheduleTask(
new Task() {
@Override
public void run() {
EventManager.fireEvent(
SceneManager.getCurrentScene(),
new Event(EventType.YOU_HAVE_BEEN_KILLED, false, false)
);
}
},
2.0f
);
}
项目:MathMemory
文件:GameScreen.java
private void addMemoryItemButtonListener(final MemorySingle button) {
button.addListener(new ClickListener(){
@Override
public void clicked(InputEvent event, float x, float y){
button.setText(Integer.toString(button.numb));
addBouncyAction(button);
stage.addActor(new Bubbles(Gdx.input.getX() - 100, game.getHeight() - Gdx.input.getY(),10));
if(!checkedButtons.contains(button))
checkedButtons.add(button);
if(checkedButtons.size() == 2){
disableAllButtons();
Timer.schedule(new Task(){
@Override
public void run() {
checkIfMatch();
enableAllButtons();
}
}, 1f);
}
}
});
}
项目:practicos
文件:Respawn.java
public void RespawnEnemy() {
Timer.schedule(new Task(){
@Override
public void run() {
tics++;
if(tics > 25){
tics = 1;
}
if (tics == 1) {enemigoSpamea = true;}
if (tics == 2) {enemigoSpamea = true;}
if (tics == 3) {enemigoSpamea = true;}
if (tics == 5) {enemigoSpamea = false;}
if(tics % 2 == 0) {go=1;} else {go=0;}
}
}
,0,30/30.0f);
}
项目:practicos
文件:PantallaGameOver.java
public void animacionGameOver() {
Timer.schedule(new Task(){
@Override
public void run() {
tics++;
if(tics > 60){
tics = 0;
}
if(tics%10==0){if(timer>0 && Juego.gameOver==0 && Juego.titleScreen==0){timer--;}}
if(tics==20 && Juego.gameOver==1){Juego.titleScreen=1;}
if(tics==20){Juego.gameOver=0;}
}
}
,0,30/35.0f);
}
项目:GdxStudio
文件:StudioPanel.java
public void setName(final Actor actor){
com.badlogic.gdx.utils.Timer.schedule(new Task(){
@Override
public void run() {
String name = actor.getClass().getSimpleName()+getNameCount(actor);
if(Scene.getCurrentScene().findActor(name) == null)
actor.setName(name);
else
actor.setName(name+"_1");
actor.setX(Scene.mouse.x-actor.getWidth()/2);
actor.setY(Scene.mouse.y-actor.getHeight()/2);
Scene.getCurrentScene().addActor(actor);
Frame.actorPanel.addActor(actor.getName());
Scene.isDirty = true;
Effect.createEffect(actor, EffectType.ScaleInOut, 1.5f, 0.5f, InterpolationType.Linear);
}
}, 0.1f);
}
项目:GdxStudio
文件:SceneEditor.java
public SceneEditor(){
super();
if(reloadAssets){
Asset.loadBlocking(); // this is the first time this Scene is created by the Stage
Content.assetPanel.updateAsset();
com.badlogic.gdx.utils.Timer.schedule(new Task(){
@Override
public void run() {
Frame.scenePanel.showStudio();
Scene.scenesMap.removeKey("gdxstudio.SceneEditor");
Frame.scenePanel.update();
}
}, 1f);
reloadAssets = false;
addField = new AddField();
}
else{
Frame.scenePanel.showStudio();
Scene.scenesMap.removeKey("gdxstudio.SceneEditor");
}
Content.studioPanel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
}
项目:ludum30_a_hole_new_world
文件:Player.java
public void beingHit() {
if (!this.invincible) {
Assets.playSound("playerHurt");
this.invincible = true;
this.state = Player.State.BeingHit;
this.stateTime = 0;
this.velocity.y = 150;
this.noControl = true;
int lifes = this.counter.lostLife();
if (lifes <= 0) {
this.die();
}
Timer.schedule(new Task() {
@Override
public void run() {
Player.this.invincible = false;
Player.this.state = Player.State.Standing;
}
}, 1.8f);
}
}
项目:bladecoder-adventure-engine
文件:CreateProjectDialog.java
@Override
protected void ok() {
try {
Ctx.project.getEditorConfig().setProperty(ANDROID_SDK_PROP, androidSdk.getText());
Ctx.project.saveProject();
} catch (Exception ex) {
String msg = ex.getClass().getSimpleName()
+ " - " + ex.getMessage();
Message.showMsgDialog(getStage(), "Error saving project", msg);
}
final Stage stage = getStage();
Message.showMsg(getStage(), "Creating project...", true);
Timer.schedule(new Task() {
@Override
public void run() {
createProject(stage);
}
},1);
}
项目:bladecoder-adventure-engine
文件:CreateResolutionDialog.java
@Override
protected void ok() {
Message.showMsg(getStage(), "Creating resolution...", true);
Timer.schedule(new Task() {
@Override
public void run() {
createResolution();
String msg = scaleImages();
if(listener != null)
listener.changed(new ChangeEvent(), CreateResolutionDialog.this);
Message.hideMsg();
if(msg != null)
Message.showMsgDialog(getStage(), "Error creating resolution", msg);
}
},1);
}
项目:bladecoder-adventure-engine
文件:Message.java
public static void showMsg(final Stage stage, final String text, final boolean modal) {
Timer.post(new Task() {
@Override
public void run() {
isModal = modal;
if (text == null) {
hideMsg();
return;
}
add(stage, text);
if (FADE_DURATION > 0) {
msg.getColor().a = 0;
msg.addAction(Actions.fadeIn(FADE_DURATION, Interpolation.fade));
}
}
});
}
项目:bladecoder-adventure-engine
文件:Message.java
public static void showMsg(final Stage stage, final String text, final float duration) {
Timer.post(new Task() {
@Override
public void run() {
isModal = false;
if (text == null) {
hideMsg();
return;
}
add(stage, text);
if (FADE_DURATION > 0) {
msg.getColor().a = 0;
msg.addAction(sequence(Actions.fadeIn(FADE_DURATION, Interpolation.fade), Actions.delay(duration,
sequence(fadeOut(FADE_DURATION, Interpolation.fade), Actions.removeActor()))));
}
}
});
}
项目:Vloxlands
文件:StateTools.java
public static void initForWorkplace(final Human human) {
Vector3 pathStart = human.getVoxelBelow();
boolean queue = StateTools.equipTool(human, human.getWorkPlace().getWorkerTool(), false, pathStart);
Structure workPlace = human.getWorkPlace();
EnterStructureJob esj = new EnterStructureJob(human, workPlace, false);
esj.setEndEvent(new Callback() {
@Override
public void trigger() {
Timer.schedule(new Task() {
@Override
public void run() {
human.changeState(human.getWorkPlace().getWorkerState());
}
}, 1);
}
});
if (queue) {
Path p = AStar.findPath(pathStart, workPlace.getStructureNode(pathStart, NodeType.entry).pos.cpy().add(workPlace.getVoxelPos()), human, NodeType.entry.useGhostTarget);
human.queueJob(p, esj);
} else human.setJob(null, esj);
}
项目:vis-editor
文件:TextureCacheModule.java
@Override
public void fileChanged (FileHandle file) {
if (ProjectPathUtils.isTexture(file)) {
cacheWaitTimer.clear();
cacheWaitTimer.scheduleTask(new Task() {
@Override
public void run () {
updateCache();
}
}, 0.5f);
}
if (ProjectPathUtils.isTextureAtlas(file) || ProjectPathUtils.isTextureAtlasImage(file)) {
atlasWaitTimer.clear();
atlasWaitTimer.scheduleTask(new Task() {
@Override
public void run () {
updateAtlas(file);
}
}, 0.5f);
}
}
项目:ead
文件:GalleryTest.java
@Override
protected Actor buildUI(Skin skin, I18N i18n) {
gallery = new Gallery(2.5f, 3, skin);
for (int i = 0; i < 3; i++) {
addItem();
}
Timer.schedule(new Task() {
@Override
public void run() {
Gdx.app.postRunnable(new Runnable() {
@Override
public void run() {
addItem();
}
});
}
}, 1, 1, 50);
return gallery;
}
项目:lilligames
文件:MicroGame.java
public MicroGame(GameScreen parent) {
Texture.setEnforcePotImages(true);
this.parent = parent;
touchPos = new Vector3();
camera = new OrthographicCamera(Gdx.graphics.getWidth(), Gdx.graphics.getHeight());
camera.position.set(Gdx.graphics.getWidth() / 2.0f, Gdx.graphics.getHeight() / 2.0f, 0);
batch = parent.batch;
font = parent.font;
timeLeft = DEFAULT_TIME_LEFT;
u = (Gdx.graphics.getWidth() / Gdx.graphics.getHeight()) * ((float)Gdx.graphics.getWidth() / MIN_PX_WIDTH);
dtlTask = new Task(){
@Override
public void run() {
decreaseTimeLeft();
}
};
decreaseTimeLeft();
}
项目:liblol
文件:Obstacle.java
/**
* Make the object a callback object, so custom code will run when an enemy collides with it
*
* @param delay The time between when the collision happens, and when the callback code runs.
* Use 0 for immediately
* @param callback The code to run when an enemy collides with this obstacle
*/
public void setEnemyCollisionCallback(final float delay, final CollisionCallback callback) {
mEnemyCollision = new CollisionCallback() {
@Override
public void go(WorldActor self, final WorldActor ps, final Contact c) {
// run the callback after a delay, or immediately?
if (delay <= 0) {
callback.go(Obstacle.this, ps, c);
} else {
Timer.schedule(new Task() {
@Override
public void run() {
callback.go(Obstacle.this, ps, c);
}
}, delay);
}
}
};
}
项目:Parasites-of-HellSpace
文件:SpawningFactory.java
public void create()
{
gamePacks = new Stack<GamePack>();
Timer.schedule(new Task()
{
@Override
public void run()
{
int choiceRandomness = MathUtils.random(3);
switch(choiceRandomness)
{
case 0:
gamePacks.add(new AmmoPack());
break;
case 1:
gamePacks.add(new HealthPack());
break;
case 2:
gamePacks.add(new UpgradePack());
break;
case 3:
gamePacks.add(new GodPack());
break;
default:
break;
}
//Timer.instance().clear();
}
}, 1, intervalBetweenGifts);
}
项目:Polymorph
文件:Splash.java
public Splash(final Polymorph polymorph) {
this.polymorph = polymorph;
batch = new SpriteBatch();
initAssets();
Timer.schedule(new Task() {
@Override
public void run() {
polymorph.setScreen(new MainMenu(polymorph));
}
}, 3); //change screen after 3 seconds
}
项目:cgc-game
文件:CGCTimer.java
public CGCTimer(Task task, float delay, boolean looping, String name)
{
myTask = task;
myDelay = delay;
myTimePassed = 0.0f;
myRepeats = 0;
timesRepeated = 0;
infinite = looping;
this.name = name;
}
项目:cgc-game
文件:CGCTimer.java
public CGCTimer(Task task, float delay, int repeat)
{
myTask = task;
myDelay = delay;
myTimePassed = 0;
myRepeats = repeat;
timesRepeated = 0;
infinite = false;
}
项目:Space-Bombs
文件:Server.java
private void activateGameTimer()
{
Timer.schedule(new Task()
{
@Override
public void run()
{
gameTimer += 1;
}
}
, 1 // first execute delay
,1 // delay between executes
);
}
项目:advio
文件:Level.java
public void lose() {
lost = true;
runTime = 0;
Timer.schedule(new Task() {
public void run() {
Advio.instance.setScreen(new GameScreen(Advio.instance.constants.resetLevel(id)));
}
}, 1);
}
项目:GDXJam
文件:WaveSystem.java
public static void initalizeSpawns(){
Task task = new Task() {
@Override
public void run () {
WaveSystem.spawnSquad(spawnPoints.random(), Constants.enemyFaction, 3);
}
};
Timer.schedule(task, 5.0f, 10.0f);
}
项目:GDXJam
文件:WaveSystem.java
private void beginWave(WaveParam wave){
Task task = new Task() {
@Override
public void run () {
WaveSystem.spawnSquad(spawnPoints.random(), Constants.enemyFaction, 5);
}
};
Timer.schedule(task, 0.0f, wave.spawnInterval, wave.squadCount);
}
项目:GDXJam
文件:GUISystem.java
private void initAlertTasks(){
resourceAlertTask = new Task() {
@Override
public void run () {
Color color = ALERT_COLOR;
if(resourceLabel.getColor().equals(ALERT_COLOR))
color = DEFAULT_COLOR;
resourceLabel.setColor(color);
}
};
}
项目:umbracraft
文件:ItemListModule.java
private void updateIcon() {
iconTable.clear();
String path = Editor.db().config().projectPath + Editor.db().config().iconPath + definition.icon + ".png";
if (Gdx.files.absolute(path).exists()) {
final Texture texture = new Texture(Gdx.files.absolute(path));
iconTable.add(new Image(texture)).size(texture.getWidth() * 2, texture.getHeight() * 2);
}
Timer.schedule(new Task() {
@Override
public void run() {
updateIcon(); // lazy af
}
}, 1);
}
项目:umbracraft
文件:AudioManager.java
/** Plays a sound after some delay.
* @param delay the delay, in seconds
* @param path the path to the sound */
public void delayedSound(final float delay, final String path) {
Timer.schedule(new Task() {
@Override
public void run() {
sound(path);
}
}, delay);
}
项目:practicos
文件:CambioPantalla.java
public void animacionPuerta() {
Timer.schedule(new Task(){
@Override
public void run() {
tics++;
if(tics > 30){
tics = 0;
roundTics++;
}
if(roundTics > 20){
roundTics = 0;
}
if(estadoPuerta==1){
if(xIzq<-3){xIzq++;}
if(xDer>160){xDer--;}
if(xIzq==-3 && xDer==160){estadoPuerta=2; roundTics=0; tics=0; if(Juego.titleScreen==2){Juego.titleScreen=0;} }
}
if(estadoPuerta==2){
if(roundTics==2) {dibujarLetrero=1;}
if(roundTics==3) {estadoPuerta=3; roundTics=0; tics=0;}
}
if(estadoPuerta==3){
if(roundTics==4 && letreroPuerta==1) { dibujarLetrero=0; }
if(xIzq>-163&&roundTics>5){xIzq--;}
if(xDer<320&&roundTics>5){xDer++;}
if(xIzq==-163 && xDer==320){estadoPuerta=0; tics=0;}
}
}
}
,0,1/251.0f);
}
项目:libgdxcn
文件:DragScrollListener.java
public DragScrollListener (final ScrollPane scroll) {
this.scroll = scroll;
scrollUp = new Task() {
public void run () {
scroll.setScrollY(scroll.getScrollY() - getScrollPixels());
}
};
scrollDown = new Task() {
public void run () {
scroll.setScrollY(scroll.getScrollY() + getScrollPixels());
}
};
}
项目:libgdxcn
文件:TimerTest.java
@Override
public void create () {
Timer timer = new Timer();
Task task = timer.scheduleTask(new Task() {
@Override
public void run () {
Gdx.app.log("TimerTest", "ping");
}
}, 1, 1);
Gdx.app.log("TimerTest","is task scheduled: "+String.valueOf(task.isScheduled()));
}
项目:top-down-shooter
文件:HelloApp.java
private void initPlane(){
Timer.schedule(new Task() {
@Override
public void run() {
if (propellerNumber == 2)
propellerNumber = 1;
else
propellerNumber++;
propeller.setTexture(propTexArray.get(propellerNumber-1));
}
}, 0, 1 / 30.0f);
}
项目:top-down-shooter
文件:HelloApp.java
private void scheduleEnemies(){
Timer.schedule(new Task() {
@Override
public void run() {
EnemiesAndClouds();
}
}, 0, 1.0f);
}
项目:FloppyThreeD
文件:ClassicGameScreen.java
private void playerdie(){
//play sound and wait
dieSound.play();
dead = true;
Timer.schedule(new Task(){
@Override
public void run() {
if(!settingsManager.getquickreset())
g.setScreen(new MainMenuScreen(g, nface, score));
}
}, 1);
}
项目:FloppyThreeD
文件:FirstPersonScreen.java
private void playerdie(){
//play sound and wait
dieSound.play();
dead = true;
Timer.schedule(new Task(){
@Override
public void run() {
if(!settingsManager.getquickreset())
g.setScreen(new MainMenuScreen(g, nface, score));
}
}, 1);
}
项目:MathAttack
文件:WorldLayerActors.java
/**
* Kill hero.
*/
public void killHero() {
hero.setAnimationMomentary(HeroAssests.hero_faint, true, null, true, true);
Timer.schedule(new Task() {
@Override
public void run() {
gameManager.setGameState(GameState.GAME_OVER);
}
}, 0.9f);
}
项目:libgdx
文件:LevelManager.java
/**
* Hace aparecer un nuevo Item en la pantalla
* @param x Posici�n x
* @param y Posici�n y
*/
public static void raiseItem(final int x, final int y) {
Timer.schedule(new Task(){
@Override
public void run() {
Item item = new Item();
item.position.set(x, y);
LevelManager.items.add(item);
}
}, 1);
}
项目:libgdx
文件:Player.java
/**
* Coloca una bomba en la posición actual
*/
public void putBomb() {
if (activeBombs < bombsLimit)
if (timeBeetwenBombs >= BOMB_RATE) {
// Recalcula la posición para la que la bomba se alinee con los ladrillos
int x = Math.round(position.x / 16) * 16;
int y = Math.round(position.y / 16) * 16;
final Bomb bomb = new Bomb(ResourceManager.getTexture("bomb_idle"), x, y,
bombLength, bombStrength, spriteManager);
spriteManager.bombs.add(bomb);
timeBeetwenBombs = 0;
activeBombs++;
// Marca la bomba para explotar en 2 segundos y desaparecer en 3
Timer.schedule(new Task() {
public void run() {
bomb.explode();
activeBombs--;
}
}, 2);
Timer.schedule(new Task() {
public void run() {
bomb.die();
}
}, 2.5f);
}
}
项目:libgdx
文件:Enemy.java
public void explode() {
exploding = true;
speed = 0f;
// En 1.5 segundos desaparecerá de la pantalla
Timer.schedule(new Task() {
public void run() {
die();
}
}, 1.5f);
}