kenyee Posted February 23, 2014 Share Posted February 23, 2014 Anyone know of an upgrade guide going from one version to another? For the timer, looks like you can do this: //cloudsTimer = new Phaser.Timer(game); //cloudsTimer.onEvent.add(spawnCloud); //cloudsTimer.start(); //cloudsTimer.add(Math.random()); game.time.events.add(Phaser.Timer.SECOND * Math.random()*2, spawnCloud, this); and get rid of the cloudsTimer.update() and stop/start later on. The new timer events are one-shots, so you add them again instead of stopping the timer and bumping the next event timepoint like you used to do in 1.1.3. But other stuff seems broken too:1) sprites seem to be appearing midway across the screen instead from the right edge2) gravity no longer seems to be activated by doing allowGravity=true on a sprite FWIW, I've always thought that 0.0.x upgrades should *not* break existing APIs. Only major upgrades or big point upgrades should and they should be fairly well documented... Sounds also doesn't seem to work in cocoonjs w/ Phaser 1.1.3 but that seems to be fixed in the trunk version. Link to comment Share on other sites More sharing options...
rich Posted February 24, 2014 Share Posted February 24, 2014 I'd say that Timer wasn't "broken" as it was highly experimental (and documented as such) in 1.1.3, and aside from a few focus loss issues now works as intended. Also game.time.events.add isn't a replacement for creating a new timer - that's just for one-shot events. Look at the examples/time/timed slideshow to see how you'd create an equivalent now. Gravity values were actually wrong in 1.1.3 and corrected in 1.1.4, but I can see how it might look like the opposite. It was in the readme, but then so were hundreds of other things, so it was easy to miss. allowGravity still works as it did before, you just need a much higher value now. 1.1.4 definitely has a more flakey physics system, and it's painfully easy to break it, but actual API changes were quite minimal really. The changes from 1.x to the 2.0 release are massive however, hence the re-numbering. Link to comment Share on other sites More sharing options...
angelts Posted April 8, 2014 Share Posted April 8, 2014 Kenyee, you are absolutely right- upgrade from 1.1.3. to 2.0.2. is absolute disaster and epic, EPIC failure (especially in Timers classes). In your example, the showing code for the Timers about cloudsTimer and fingersTimer (from main.js of FlappyBird code), can't be reconstructed EASY (maybe no way at all) in newest version. Sure path to the end and death of this beautiful project. Link to comment Share on other sites More sharing options...
Heppell08 Posted April 8, 2014 Share Posted April 8, 2014 I just wouldnt upgrade if you are in too deep with a previous version and if you 'needed' to upgrade then go for it. I'm using 1.1.5 but could easily go up into 2.0.2 with an alt build i have but some things work fine and the things that dont work fine were removed during the main development anyway.My advice is to have a main build and an alt build. Practice with the alt and code with the main whether it be in 1.1.3, 1.1.5 etc etc Link to comment Share on other sites More sharing options...
rich Posted April 8, 2014 Share Posted April 8, 2014 Kenyee, you are absolutely right- upgrade from 1.1.3. to 2.0.2. is absolute disaster and epic, EPIC failure (especially in Timers classes). In your example, the showing code for the Timers about cloudsTimer and fingersTimer (from main.js of FlappyBird code), can't be reconstructed EASY (maybe no way at all) in newest version. Sure path to the end and death of this beautiful project. Sorry but that's ridiculous. Timers were massively broken in 1.1.3 in lots of cases and fixed in the 2.0.0 release - the list of github issues relating to them that were resolved in v2 alone is huge. I also disagree that you can't reconstruct the example code at the start of this thread using 2.0. If anything it's easier now than it was before. We published a large 1.x to 2.0 Migration Guide for a reason: To read. Link to comment Share on other sites More sharing options...
angelts Posted April 9, 2014 Share Posted April 9, 2014 I spent 1.5 days to upgrade main.js (Flappy Bird) from original Phaser 1.1.3 to newest 2.0.2. Finally I got it. Here is the code. function create() { //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.physics.startSystem(Phaser.Physics.ARCADE); ... //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): clouds.enableBody = true; ... //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): fingers.enableBody = true; ... //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): invs.enableBody = true; ... //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.physics.arcade.enable(birdie); ... //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.physics.setBoundsToWorld(); ... // Start clouds timer //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //cloudsTimer = new Phaser.Timer(game); //cloudsTimer.onEvent.add(spawnCloud); //cloudsTimer.start(); //cloudsTimer.add(Math.random()); //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.time.events.add(1000 * Math.floor((Math.random()*1)+1), spawnCloud); ... } function start() { ... // SPAWN FINGERS! //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //fingersTimer = new Phaser.Timer(game); //fingersTimer.onEvent.add(spawnFingers); //fingersTimer.start(); //fingersTimer.add(2); //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.time.events.add(1000, spawnFingers); } function spawnCloud() { //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //cloudsTimer.stop(); ... //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //cloudsTimer.start(); //cloudsTimer.add(4 * Math.random()); //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.time.events.add(1000 * Math.floor((Math.random()*20)+1), spawnCloud); } function spawnFingers() { //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): if ( gameOver ) return false; //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //fingersTimer.stop(); //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //var fingerY = ((game.height - 16 - o() / 2) / 2) + (Math.random() > 0.5 ? -1 : 1) * Math.random() * game.height / 6; //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): var fingerY = (((game.world.height) - 16 - o() / 2) / 2) + (Math.random() > 0.5 ? -1 : 1) * Math.random() * game.world.height / 6; ... //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //inv.width = 2; //inv.height = game.world.height; //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): inv.body.width = 2; inv.body.height = game.world.height; ... //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //fingersTimer.start(); //fingersTimer.add(1 / SPAWN_RATE); //Only for Phaser 2.0.2 (not need for Phaser 1.1.3): game.time.events.add(1000 * SPAWN_RATE, spawnFingers); return true; } function setGameOver() { ... // Stop spawning fingers //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //fingersTimer.stop(); ... } function update() { if (gameStarted) { ... // Update finger timer //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //fingersTimer.update(); } else { ... } ... // Update clouds timer //Only for Phaser 1.1.3 (not need for Phaser 2.0.2): //cloudsTimer.update(); ... } Link to comment Share on other sites More sharing options...
Recommended Posts