Search the Community

Showing results for tags 'timer'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Platform
    • Coding and Game Design
  • Frameworks
    • Phaser 3
    • Phaser 2
    • Pixi.js
    • Babylon.js
    • Panda 2
    • melonJS
  • General
    • General Talk
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 68 results

  1. Hello everyone, I am trying to create a timer that will count down three minutes after the state was started. I am not sure how to make a text that will visualize the timer.(00:00) Can you guys help out?
  2. Just trying to change the game state on a timer event. Currently working with this.time.events.add(3000, this.state.start, this, 'state_name');in a logo state I wanted to stay around for three seconds before starting up the next state. The events goes off, but the function doesn't execute. Giving back "Uncaught TypeError: this.checkState is not a function". Any suggestions on how to get around this, and any idea what's going on under the hood to cause this?
  3. Hey! I want the weapons of a spaceship to shoot in volleys / bursts, meaning it should fire some bullets with a delay in between, reload and then repeat. I'm trying to accomplish this with simple repeat timers: // Slightly modified code fire = function() { for (var i = 0; i < weapons.length; i++) { var weapon = weapons[ i ]; if (game.time.now >= weapon.next) { // Reset reload delay (1000ms) weapon.next = game.time.now + weapon.rate; // Shoot 5 bullets with 100ms duration between game.time.events.repeat(100, 5, function() { new Bullet(game, { x: weapon.world.x, y: weapon.world.y, angle: ship.rotation }); }, game); } } } My problem is that, for some odd reason, all bullets shoot from the same weapon. The timer always takes the x, y and angle values of the last given element, no matter if i iterate the weapons with a loop or do it manually for each. Even random values don't work. Any idea? It makes no sense to me
  4. Hi there, I have a problem with game mechanics on mobile devices. Mechanics connected with timers. For example, I have a physics character (using p2 physics), which fly up during some time, then falling down. So the problem is my character fly on different heights on different devices. I think it's a problem with performance and game fps. I've tried to connect mechanics with game.time.fps - but it's don't help. Maybe anybody have some ideas what is going on? This is the part of code for example: function fly() { if (timer1.ms < force + 50/*I've tried to add fps here, but no effect*/) { sprite.body.data.gravityScale = -2; } else if (timer1.ms > force - 50) { sprite.body.data.gravityScale = 2; } } var timer1 = application.game.time.create(false); timer1.repeat(myTime, 3, fly); timer1.start(); I use phaser 2.4.4
  5. Hi all, I want to do something simple, tell a Phaser.Timer to: repeat 10 times in speed A, wait A seconds then repeat 3 times in speed B, wait B seconds then repeat X times in speed C wait C seconds etc... Is there a simple way of doing that? thanks! Lior
  6. Hello. I'm newbie to Phaser. I need to create countdown timer for game starting. It should looks like counting from 3 to 1, then the game should be started. I'll be using images as a numbers. i Have the following game state's Boot StartMenu Game GameOver I thought that i need to create state "PreGame", where will be countdown timer code. Is this correct? And help me pls with writing timer using images. Could someone help me with this.
  7. In my code, I am using the following to create a timer that counts down: var counter = 60;create: function () {timerText = game.add.text(game.world.centerX, game.world.centerY, 'TIMER: 60', {font: '15px Arial', fill: '#FFFFFF', align: 'center'});timerText.anchor.setTo(0.5, 12.4);game.time.events.loop(Phaser.Timer.SECOND, this.updateCounter, this);}updateCounter: function () {counter -= 1;timerText.setText('TIMER: ' + counter);}, timeUp: function () {stateText.text="GAME OVER";stateText.visible = true; },The above works as expected -- my problem is that when the game ends and the user plays again the timer becomes glitchy showing at times negative numbers or starting at weird places .. I assume what I need to do is reset the time or detroy the timer at the game end function but I have been unsuccesful in figuring out how to do so -- Any guidance would be greatly appreciated --- I think it is probably something simple -- but I could be wrong ---
  8. I am a new joiner and meet following issue need help, many thx. I have following coding in my update: function( ){ } function, if (bid_ending_flag == true){ //countdown console.log('[On update]:started.'); countdown_timer = 10; timerEvent = this.time.events.loop(this.game.Timer.SECOND, this.updateTimer);in my updateTimer function is like this: updateTimer: function(){ countdown_timer -= 1; if(countdown_timer === -1) { this.time.events.remove(timerEvent); <--error happened here setTimeout(countDownText.destroy(), 1000); } else { countDownText.setText(countdown_timer); <-- this worked properly }},Once bid_ending_flag is true, the countdown could be work count from 9 to 0, but the problem happened, always popup error message say : [Error] TypeError: 'undefined' is not an object (evaluating 'this.time.events') in my updateTimer function. I have no idea and hope to get any expert's help. thanks advance again.
  9. Hi Is it possible to use a Phaser.Timer to update a progressbar? timer1 = game.time.events.loop(Phaser.Timer.SECOND, playerAttack1, this);I need to be able to find out how far through a loop my timer is - something like (sloppy code but you get what I mean): var timeleft = timer1.time.next - timer1.time.start;var progressPercent = timeleft / timer1.time.length;the problem I have is that I am not sure how to get timer1.time.start - I can get the start of the timer, but not the start of the last loop. thanks in advance!
  10. Hi, I'm working on a simple platformer and I'm trying to get the player to play his idle animation when a timer reaches 0. I looked at the Basic Repeat Event example to get a sense of things. I tried two ways but didn't get the correct results. V1: Sprite will flicker with the first frame of the idle animation, but does not play it through. function create() { player.animations.add('idle', [4, 15], 10, false); game.time.events.repeat(Phaser.Timer.SECOND * 2.5, 10, idleAnim, this);}function idleAnim() { if (player.body.velocity.x === 0 && player.body.touching.down) { player.animations.play('idle'); }}V2: After the timer ticks, nothing happens until I move my character left or right, in which case, he gets stuck in the first frame of the idle. var goIdle = 0;function create() { player.animations.add('idle', [4, 15], 10, false); game.time.events.repeat(Phaser.Timer.SECOND * 2.5, 10, idleAnim, this);}function idleAnim() { if (player.body.velocity.x === 0 && player.body.touching.down) { goIdle = 1; } else goIdle = 0;}function update() { if (goIdle === 1) { player.animations.play('idle'); };I feel like I'm missing something totally obvious. Also, as a side note, does the repeat function need to have a repeat count? Could I leave that out if I wanted it to tick infinitely? Thanks!
  11. MarvinB

    Timer

    Hey Guys, I am trying to implement a simple countdown to my game. Unfortunately, Phaser is throwing the following error: Uncaught TypeError: Cannot read property 'apply' of undefined The error occurs in this line in Phaser: this.events[this._i].callback.apply(this.events[this._i].callbackContext, this.events[this._i].args); The loop function calls my method once, so it counts down once and then throws the error. I am assuming the callback is not called correctly and therefore the event[this_i].callback is undefined. This is my code: ....... MMM.thisCountDown[id] = countdown; MMM.timerText[id] = this.game.add.text(0, 0, countdown, style); MMM.timerText[id].anchor.set(0.5); MMM.timerText[id].x = Math.floor(textbox.x+2); MMM.timerText[id].y = Math.floor(textbox.y+2); MMM.timerEvent[id] = this.game.time.events.loop(Phaser.Timer.SECOND, this.updateTimer(id)); MMM.backgroundobjects.add(textbox); } updateTimer(id) { MMM.thisCountDown[id] -= 1000; if(MMM.thisCountDown[id] === 0) { //to remove loop event this.game.time.events.remove(timerEvent[id]); MMM.timerText[id].setText("EXP"); } else { MMM.timerText[id].setText(MMM.thisCountDown[id]); } }
  12. I'm working on a game where the player must complete a level within 30 seconds. If the player succeeds the timer is stopped, a message displays, the next level starts and the timer must be reset to 30 seconds. This all happens within the same Phaser.state. The time display only needs to be updated each second, not in between, so I looked at this example and use a time-object and initialise it with .loop() and then .start() it. When the time runs out or when player wins the timer is stopped with .stop(). The problem is that timer.Start() doesn't seem to work after the timer.Stop() was called. If looked at .pause() and resume() but I think(?) then it can potentially continue mid-second in the next level (time is very important in this game) not sure though.. Here's what I've got so far, I've isolated the code for the clock update in an example test program, see code below. var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create }); var clocktext; // bitmaptext var clocktimer; // Phaser.timer var clockseconds; // integer // ------------------------------------- // PHASER GAME FUNCTIONS // ------------------------------------- function preload() { game.load.bitmapFont('myfont', 'myfont.png', 'myfont.xml'); }; function create() { // add texts clocktext = game.add.bitmapText(160, 160, 'myfont', '---', 40); game.add.bitmapText(160, 160+80, 'myfont', 'Press R to reset timer', 40); game.add.bitmapText(160, 160+120, 'myfont', 'Press S to stop timer', 40); // timer object, note timer won't start running yet clocktimer = game.time.create(false); clocktimer.loop(Phaser.Timer.SECOND, updateDisplay, this); // handle keyboard keys R and S game.input.keyboard.onDownCallback = HandleKeyDown; clockseconds = 0; } function HandleKeyDown(e) { if (e.keyCode == 82) { initClock() }; // R = reset/init if (e.keyCode == 83) { stopClock() }; // S = stop/pause } function stopClock() { clocktimer.stop(); clocktext.text = "Stop at " + clockseconds + " seconds left"; console.log('stopClock - timer stopped'); } function initClock() { clockseconds = 5+1; // set countdown seconds, +1 because initial display will also decrease with 1 updateDisplay(); // initial display clocktimer.start(); } function updateDisplay() { // count down seconds clockseconds = clockseconds - 1; console.log('updateClock - seconds left: '+clockseconds); // check if time is up if (clockseconds <= 0) { // ohnoes! stopClock(); console.log('updateClock - time is up'); clocktext.text = 'time is up!'; } else { // update display var minutes = Math.floor(clockseconds / 60); var seconds = (clockseconds - minutes * 60); clocktext.text = "time " + (("0"+minutes).substr(-2) + ":" + ("0"+seconds).substr(-2)); }; } btw there's also this thread but that only explains how to start a timer, not how to stop and restart it.
  13. In my memory game there are two loop timers, one which runs on each 100 milliseconds and second on each 1000 milliseconds. We cannot forget also the update() function which comes along the Phaser.State class. In the 100 mil timer I do stuff like replacing cards by position, and showing helper arrows. On the 1000 mil timer I just increment the clock by one second. All works well but the code got kind of too cluttered so I am afraid, I could break something at this point. For best performance, is it good to use only one timer and no update() method or should I just move all in update() method and count the number of frames passed?
  14. I'm creating loops like this: this.someLoop = this.game.time.events.loop(Phaser.Timer.SECOND * 2, callbackMethod, this); this.someOtherLoop = this.game.time.events.loop(Phaser.Timer.SECOND * 5, callbackMethod, this); The problem is when I pause one of them, the rest pause as well: this.someLoop.timer.pause() will also cause this.someOtherLoop to pause. How can I stop / pause individual loops? Also, how can I send to the garbage collector a loop? Thanks!
  15. Okay so current project I'm working on is to make a platformer game which uses just a single level design but multiple stages featuring different mechanics in it. I have a death counter which counts the number of times the player jumps into the spikes from which upon dying they will respawn back at the beginning of the level I also have a timer which is counting the amount of time it take to complete the level. Now what I want to do is make it so upon reaching the pipes at the end of the level when they switch over to the next level the values from the death counter & level timer will carry over to the next level. So e.g. Level 1 - Stage 1 = 20 deaths and a finishing time of 50 seconds. Upon starting Level 1 - Stage 2 the death counter will start at 20 and the level timer will resume counting from 50 seconds. instead of at 0. Currently they're simply resetting back to 0 as you can see in the create function below. How would I go about doing this as I noticed there's not anything in the examples that can show me how to do this? My game can be accessible from http://mbrooks.bitbucket.org Code as follows - BasicGame.Game = function (game){ // When a State is added to Phaser it automatically has the following properties set on it, even if they already exist: this.game; // a reference to the currently running game this.add; // used to add sprites, text, groups, etc this.camera; // a reference to the game camera this.cache; // the game cache this.input; // the global input manager (you can access this.input.keyboard, this.input.mouse, as well from it) this.load; // for preloading assets this.math; // lots of useful common math operations this.sound; // the sound manager - add a sound, play one, set-up markers, etc this.stage; // the game stage this.time; // the clock this.tweens; // the tween manager this.state; // the state manager this.world; // the game world this.particles; // the particle manager this.physics; // the physics manager this.rnd; // the repeatable random number generator this.map; this.layer; this.player; this.cursors; this.spikes; this.deathCounter; this.spikesCollision = false; this.stageTip; this.stageNumber; this.deathText; this.levelText; this.tipText; this.timeText; this.levelStartTime = 0; this.levelCurrentTime = 0;// this.deathTemp;// this.total; //this.timer; // You can use any of these from any function within this State. // But do consider them as being 'reserved words', i.e. don't create a property for your own game called "world" or you'll over-write the world reference.};BasicGame.Game.prototype ={ create: function () { console.log('Creating game state!'); //Change the stagebackgroundColour to classic Mario blue. //this.stage.backgroundColor = '#6888ff'; //Populate the local map attribute with the tilemap with they key "level" map = this.add.tilemap('level-' + BasicGame.current_level_id); //map = this.add.tilemap('level' + BasicGame.current_level_id); //Assign the "level_tiles" tileset to the tilemap data map.addTilesetImage('level_design', 'level-' + BasicGame.current_level_id); //map.addTilesetImage('level_design', 'level_tiles' + BasicGame.current_level_id); //Populate the local layer with the combined level data. layer = map.createLayer('level_design'); //Resize the game world to fit the level data. layer.resizeWorld(); this.physics.startSystem(Phaser.Physics.ARCADE); map.setTileIndexCallback([12,13,14,15], this.PlayerDie, this); map.setTileIndexCallback([21, 25,26], this.nextStage, this); map.setTileIndexCallback(29, this.ButtonPressed, this); map.setCollision([0,1,2,3,4,5,25,26,27,28], true); player = this.add.sprite(135, 110, 'mario'); //total = 0; deathCounter = 0; // deathCounter = deathTemp; this.physics.arcade.enable([player]); this.physics.arcade.gravity.y = 500; player.body.collideWorldBounds =true; player.body.setSize(12, 16, 2, 0); cursors = this.input.keyboard.createCursorKeys(); player.animations.add('run',[0,1,2],10,true); player.animations.add('stand',[6]); //Shows the stage number for this stage deathText = this.game.add.text(1050, 725, 'Total Deaths: 0', { font: '20px Arial', fill: '#fff', align: 'center' }); if (BasicGame.current_level_id == 1) { levelText = this.game.add.text(125, 725, 'Level 1 - Stage 1', { font: '25px Arial', fill: '#fff', align: 'center' }); tipText = this.game.add.text(125, 770, 'Normal Movement', { font: '20px Arial', fill: '#fff', align: 'center' }); } else if (BasicGame.current_level_id == 2) { levelText = this.game.add.text(125,725, 'Level 1 - Stage 2', { font: '25px Arial', fill: '#fff', align: 'center' }); tipText = this.game.add.text(125,770, 'Inverted Movement', { font: '20px Arial', fill: '#fff', align: 'center' }); } /* else if (BasicGame.current_level_id == 2) { levelText = this.game.add.text(125,725, 'Level 1 - Stage 2', { font: '25px Arial', fill: '#fff', align: 'center' }); tipText = this.game.add.text(125,770, 'Inverted Movement / Verted Movement Timer', { font: '20px Arial', fill: '#fff', align: 'center' }); this.timer.game.time.create(false); this.timer.loop(2000, update, this); this.timer.start(); }*/ timeText = this.game.add.text(1050, 770, 'Time: ' + 's', { font: '20px Arial', fill: '#fff', align: 'center' }); this.levelStartTime = this.game.time.time; }, update: function () { // Honestly, just about anything could go here. It's YOUR game after all. Eat your heart out! this.physics.arcade.collide(player, layer); if (BasicGame.current_level_id == 1) { if (cursors.left.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = -175; //Play the run animation player.animations.play('run'); } //Check if the right arrow is down else if (cursors.right.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = 175; //Play the run animation player.animations.play('run'); } //Neither direction is pressed. else { //Remove the player's physics body's horizontal velocity. player.body.velocity.x = 0; //Play the Stand animation player.animations.play('stand'); } //if the up arrow is pressed and mario is touching another physics body below. if (cursors.up.isDown && player.body.onFloor()) { //Give the player's physics body some vertical velocity. player.body.velocity.y = -375; } } else if (BasicGame.current_level_id == 2) { if (cursors.left.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = 175; //Play the run animation player.animations.play('run'); } //Check if the right arrow is down else if (cursors.right.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = -175; //Play the run animation player.animations.play('run'); } //Neither direction is pressed. else { //Remove the player's physics body's horizontal velocity. player.body.velocity.x = 0; //Play the Stand animation player.animations.play('stand'); } //if the up arrow is pressed and mario is touching another physics body below. if (cursors.up.isDown && player.body.onFloor()) { //Give the player's physics body some vertical velocity. player.body.velocity.y = -375; } } /* else if (BasicGame.current_level_id == 2) { total++ // if(total == 1) //{ if (cursors.left.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = -175; //Play the run animation player.animations.play('run'); } //Check if the right arrow is down else if (cursors.right.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = 175; //Play the run animation player.animations.play('run'); } //Neither direction is pressed. else { //Remove the player's physics body's horizontal velocity. player.body.velocity.x = 0; //Play the Stand animation player.animations.play('stand'); } //if the up arrow is pressed and mario is touching another physics body below. if (cursors.up.isDown && player.body.onFloor()) { //Give the player's physics body some vertical velocity. player.body.velocity.y = -375; } //} if (total == 2) { if (cursors.left.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = 175; //Play the run animation player.animations.play('run'); } //Check if the right arrow is down else if (cursors.right.isDown) { //Give the player's physics body some velocity on the x (horizontal axis). player.body.velocity.x = -175; //Play the run animation player.animations.play('run'); } //Neither direction is pressed. else { //Remove the player's physics body's horizontal velocity. player.body.velocity.x = 0; //Play the Stand animation player.animations.play('stand'); } //if the up arrow is pressed and mario is touching another physics body below. if (cursors.up.isDown && player.body.onFloor()) { //Give the player's physics body some vertical velocity. player.body.velocity.y = -375; } total = 0; } }*/ this.levelCurrentTime = this.game.time.time - this.levelStartTime; timeText.setText('Time: ' + this.levelCurrentTime/1000 + 's') }, ButtonPressed: function(sprite, tile) { map.replace(29, 31); map.replace(19, 41); }, nextStage: function(sprite, tile) { console.log("Next Level!"); BasicGame.current_level_id++; // deathTemp = deathCounter; this.game.world.setBounds(0, 0, 0, 0); //This Ensures the Level Bounds are reset this.game.state.start("Game", true, false); }, PlayerDie: function(sprite, tile) { deathCounter++; deathText.setText('Total Deaths: ' + deathCounter); sprite.kill(); player.reset(135, 110) map.replace(41, 19); map.replace(31, 29); }, quitGame: function (pointer) { // Here you should destroy anything you no longer need. // Stop music, delete sprites, purge caches, free resources, all that good stuff. // Then let's go back to the main menu. this.state.start('MainMenu'); }}
  16. I have this loop in my GameScreen state: timeCounter = function () { timeElapsed += 1; levelTimeText.update(); if (cardGroup.countLiving() === 0) { gameObject.time.events.stop(false); showLevelCompletePanel(); }}GameScreen = { init: function () { gameObject.time.events.loop(TIMER_DELAY, timeCounter); gameObject.time.events.start(); }}So each time I enter GameScreen state the loop should start counting, but it works only the first time. So I enter first time. All works and then when I enter GameScreen again, the loop doesn't start at all. What do I do wrong, or what could be happening with the loop?
  17. I want custom timer. I make a memory game i.e I have to choose from a set of cards and find all the pairs. So if I pick two non-equal cards my timer should run their closing animation. I did this: cardTimer = new Phaser.Timer(gameObject, false); cardClosingEvent = function () { // doo some stuff cardTimer.stop(false); } cardTimer.add(1000, cardClosingEvent); openCards =function () { // do some stuff cardTimer.start(); } if I log the timer object in console, the events subarray is empty. Not sure what it goes wrong. It is like the TimerEvent is removed from the timer after the timer runs once.
  18. I am using the phaser loop and it is really powerful I have a couple questions about how to do things before I use it. this.timeKeeper = 5000; this.starTimer.loop(this.timeKeeper, this.addStar, this); How would I keep score of every time this loop gets called? How would I increase the loop speed when the score increases? I have a demo I hope you can checkout http://jsbin.com/xijocikihe/1/edit?js,output I have tried to put this in the update method but didn't work if (this.score === 500){ this.timeKeeper = 1000; }
  19. Hi everyone, I juste have a little question. How can I do for doing something evey 5 secondes ?
  20. In my game, i have a timer event which will run for 60 seconds. This is a startGame function in coffeescript. Which has a time event in bold letters. I passed @seconds_counter value which is 60. So this timer will count till 60 seconds and afterthat calls @removeCounter function. startGame: -> left_button = @add.button(60, 350, 'button', @checkAnswerForLeft, this) right_button = @add.button(460, 350, 'button', @checkAnswerForRight, this) @time.events.remove @timer # Start main game counter @seconds_timer = @time.events.loop(Phaser.Timer.SECOND, @updateSecondsCounter, this) @time.events.add Phaser.Timer.SECOND * @seconds_counter, @removeCounter, this In my game i want to give users a time bonus in which i want to add extra seconds to this time event. I added 10 seconds to @seconds_counter but it won't affect this timer event. So in short, my game loop is 60 seconds. If user get time bonus then add 10 seconds to game loop so for that user gae will be of 70 seconds and after that @removeCounter function should call. Is there any way to update time for running timer??
  21. var diff, increase_end_angle = 0, start_angle = 1.5 * Math.PI,end_angle = 2 * Math.PI, startTime = (new Date()).getTime(), circleTimer; create: function { button = this.game.add.button(0,0,'btnNext', this.start,this); }, circleTimer: function () { var graphics = game.add.graphics(0, 0); diff = (new Date()).getTime() - startTime; diff = diff / 60000; //60000ms = 60s increase_end_angle = start_angle + end_angle * diff + reduce; graphics = game.add.bitmapData(80,80); graphics.context.fillStyle = '#D24545'; graphics.context.beginPath(); graphics.context.arc(x,y,radius,start_angle,increase_end_angle,false); graphics.context.lineTo(x,y); graphics.context.fill(); graphics.context.closePath(); game.add.image(13, 8, graphics); }, start: function () { circleTimer = setInterval(this.circleTimer, 200); }, update: function() { if(diff > 1 ) { clearInterval(circleTimer); } },
  22. Hi there. My game has spaceships, and yesterday I implemented a button that allows the player to build a new spaceship. For testing purposes, I set the construction to take two seconds and set up a percentage that counts upward to 100%. So I made two timers: one that fires in 2000 milliseconds and places the ship, and one that fires every 20 milliseconds to tick the construction progress up by 1%. These are both working fine except that I'm having trouble syncing them with each other. At first, I set the timer that places the ship at exactly 2000 ms, but I found that about half the time, the ship would be placed while the percentage was still in the 90s. I figured this was understandable; I think I read somewhere that you should assume about a 50 ms margin of error. So I set the timer to 2100 ms, which helped but didn't solve it, so I set it to 2200 ms, and the ship was consistently being placed after the percentage reached 100, with a noticeable but tolerable delay. I thought I was good, until I tried the game again on my laptop. This laptop is very old with a 32-bit Pentium processor and only 1 GB of RAM, and I'm sure this accounts for the difference in timing, but the difference is way too severe. On the laptop, the ship consistently gets placed while the percentage is around 80! Can you please look at my code and tell me if there's a more robust way of setting up timers that doesn't vary so heavily based on hardware? Thanks! var constructionPercentage = 0;this.newShipButton.text.setText('Under Construction: ' + constructionPercentage + '%');this.newShipButton.text.setStyle({fill: '#035069',font: 'normal 12px Arial'});this.time.events.repeat(20,100,incrementConstructionTimer,this);this.time.events.add(2200,instantiateShip,this); function incrementConstructionTimer(){ constructionPercentage++; this.newShipButton.text.setText('Under Construction: ' + constructionPercentage + '%');}
  23. Hi all; I have a little probleme with the timer: generator[id] = enemyGenerators.create(i*32,j*32,'eGenerator');generator[id].timer = this.game.time.events.loop(1500, this.addEnemy, this);So i want from to give to the timer function the x, y parametres, but i don't know how, because i can't write like that: generator[id].timer = this.game.time.events.loop(1500, this.addEnemy(generator[id].x,generator[id].y), this);Is there any solution please ? And thank you all very much
  24. Hi, I'm struggling to get phaser to display the fps of the game. Error is: Cannot read property 'game' of undefined. I've read around a bit: http://www.html5gamedevs.com/topic/7202-pausing-and-resuming-timer/ and looked at the manual but I've hit a bit of a wall. I've got a feeling I'm probably missing something incredibly obvious... Using latest version of typescript and running in latest version of node-webkit. Code: /// <reference path="../definitions/phaser.d.ts" />class SimpleGame { game: Phaser.Game; fpsText: Phaser.Text; fps: number; timer: Phaser.Timer; constructor() { this.game = new Phaser.Game(800, 600, Phaser.AUTO, 'content', { preload: this.preload, create: this.create, update: this.update(), render: this.render() }); } preload() { console.log("preloaded"); this.game.load.image('logo', 'assets/logo.png'); this.timer = this.game.time.create(false); this.timer.game.time.advancedTiming = true; } create() { console.log("created"); this.fpsText = this.game.add.text(16, 16, 'fps: 0', { fontSize: '32px', fill: '#567' }); } update(){ } render(){ this.fpsText.text = 'fps: : ' + this.timer.game.time.fps; }}window.onload = () => { var game = new SimpleGame();};Thanks for reading
  25. Test case: http://codepen.io/anon/pen/EagxjX Using latest Chrome (39.0.2171.95 m) When game.time.events.add(seconds, fn) is called and the user minimizes the browser window, Phaser's core seemingly pauses. Even though I have set game.stage.disableVisibilityChange = true; When user maximizes the window again the fn will be called, but way, way too late. Is this normal behaviour? If so, how can I make it work even when user minimizes the window? I will probably move to setTimeout(). I know it's not accurate, but I need my app to be running when in background.