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); }
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); }
@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 ); }
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); } } }); }
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); }
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); }
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); }
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)); }
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); } }
@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); }
@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); }
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)); } } }); }
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())))); } } }); }
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); }
@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); } }
@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; }
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(); }
/** * 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); } } }; }
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); }
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 }
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; }
public CGCTimer(Task task, float delay, int repeat) { myTask = task; myDelay = delay; myTimePassed = 0; myRepeats = repeat; timesRepeated = 0; infinite = false; }
private void activateGameTimer() { Timer.schedule(new Task() { @Override public void run() { gameTimer += 1; } } , 1 // first execute delay ,1 // delay between executes ); }
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); }
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); }
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); }
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); } }; }
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); }
/** 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); }
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); }
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()); } }; }
@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())); }
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); }
private void scheduleEnemies(){ Timer.schedule(new Task() { @Override public void run() { EnemiesAndClouds(); } }, 0, 1.0f); }
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); }
/** * 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); }
/** * 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); }
/** * 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); } }
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); }