rich Posted November 10, 2014 Share Posted November 10, 2014 Hi all, Updated 25th November: Release Candidate 11 is out For a good while there has been an on-going issue with the Arcade Physics and Tweens in that they would basically run slower on slower systems, and faster the better the device/computer was. It was pretty easy to cause large delta timer spikes, which were hard to handle in your code, causing random stuttering and in worst case scenarios objects would fall through other objects / tilemaps. Thanks to the work of Pete (InsaneHero) Phaser now has a brand new fixed-step timer, which is hooked into arcade physics, particles, tilemaps and tweens automatically. What this does is decouple the update logic from the render logic and ensure that the update logic runs at a fixed frame rate. This means you can now set a frame rate for your game, and it will maintain that (from a logic perspective) regardless what happens on device. It also means that because the physics calculations are now all done on a fixed time step you'll no longer see any "tunnelling" going on (objects passing through other objects). Please note: It's still possible for 2 objects to pass through each other if they are moving fast enough that they jump through in a single update - fixed-steps can't fix this, only a continuous collision detection system can, and that isn't built into this release. The new timer also provides other benefits including the ability to slow down time. You can adjust the frame rate on the fly. Phaser will now automatically populate a "suggestedFps" value for you (in multiples of 5 fps) which is based on a 2 second average of actual elapsed time. I.e. if the suggest rate drops dramatically you could adjust in-game effects accordingly. The game loop also now tries to "catch up" frames if it is falling behind by iterating the logic update. This will help if the logic is occasionally causing things to run too slow, or if the renderer occasionally pushes the combined frame time over the FPS time. It's not a band-aid for a game that floods a low powered device however, so you still need to code accordingly. But it should help capture issues such as gc spikes or temporarily overloaded CPUs. It now detects 'spiralling' which happens if a lot of frames are pushed out in succession meaning the CPU can never "catch up". It skips frames instead of trying to catch them up in this case. Note: the time value passed to the logic update functions is always constant regardless of these shenanigans. Here are the most important changes: Signals to the game program if there is a problem which might be fixed by lowering the desiredFpsTime.desiredFps is the new desired frame rate for your game.Time.suggestedFps is the suggested frame rate for the game based on system load.Time.slowMotion allows you to push the game into a slow motion mode. The default value is 1.0. 2.0 would be half speed, and so on.Time.timeCap is no longer used and now deprecated. All timing is now handled by the fixed time-step code we've introduced.Time.now can no longer be relied upon to contain a timestamp value. If the browser supports requestAnimationFrame then Time.now will contain the high resolution timer value that rAf generates. Otherwise it will contain the value of Date.now. If you require the actual time value (in milliseconds) then please use `Time.time` instead. Note that all Phaser sub-systems that used to rely on Time.now have been updated, so if you have any code that extends these please be sure to check it. As well as all of this work, Paul (@pnstickne) has done a huge load of work in the ScaleManager. This resolves various full screen issues and generally enhances and refactors how everything worked in there. Here's a list: Scale modes can now be set independentlySwitching between fullscreen and normal correctly restores modesAlignment does not incorrectly offset in fullscreen mode (#1255)Changing scale/alignment promptly refreshes layoutisFullScreen returns a boolean, as it shouldFaster parent checks (if required)NO_SCALE should not not scale (vs previous behavior of having no behavior)Correct usage of scaleMode depending on mode He has also optimised the canvas Tilemap renderer, which should again improve performance on mobile. There are also other smaller refactors to the Pointer class, various bug fixes and the latest release of Pixi inside. As you can appreciate this is a quite large update. Although the API disruption is minimal, the amount of internal changes are large. So large that I felt this warranted being the 2.2 release. We really really need your help testing this build. If you have a game running under 2.1.x then it should be a case of just testing it under 2.2.0 without changing much (if any) code. The older the version of Phaser you use, the harder the upgrade I'm afraid. But even if you just throw a few smaller test games at it, no matter what size or complexity, it will help us out massively. I have pushed up complete builds to the Phaser dev branch, so you can just grab the js files and use those if you don't want to pull down the whole repo. I'd be very pleased if you could post issues on github (please say you're using 2.2-RC1 somewhere in the post) or you can reply to this thread here. We're in no hurry to get 2.2 released, so there is plenty of time to bake this in and get it well tested - but in order to do that we really do need your help, so please try running something under 2.2, no matter what it is, and let us know how it goes! Cheers, Rich InsaneHero, ianmcgregor, Noid and 1 other 4 Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 Also just to say we'll take this opportunity to ensure that every single example works under 2.2. So please if you've found any that are broken, DO tell us about them so we can either remove them or fix them. Thanks! Link to comment Share on other sites More sharing options...
Noid Posted November 10, 2014 Share Posted November 10, 2014 I have a "MainMenu" state with a "start" button that makes it switch to a "Game" state. The game uses tilemaps and arcade physiscs. When I click on the start button on my main menu, sometimes the player appears in the right position when the game starts, and sometimes it appears much higher on top of a platform, but on the same value of X. This seems to be random(~50% chance) but it never happens with older versions of Phaser. I'll do some tests to see if I can find a pattern and write a more helpful bug report. [uPDATE:] I'm logging the Y position of the sprite right after it's created and on each update. The sprite is initially surrounded by non collidable tiles so it has plenty of space to fall. I'm not spawning it inside collidable tiles. Normal behavior: created. Y= 2510 Game.js:80Updated. Y= 2510 Game.js:115Updated. Y= 2510.1388888888887 Game.js:115Updated. Y= 2510.4166666666665 Game.js:115Updated. Y= 2510.833333333333 Game.js:115Updated. Y= 2511.3888888888887 Game.js:115Updated. Y= 2512.083333333333 Game.js:115Updated. Y= 2512.9166666666665 Game.js:115Updated. Y= 2513.8888888888887 Glitch: created. Y= 2510 Game.js:80Updated. Y= 2510 Game.js:115Updated. Y= 2510.1388888888887 Game.js:115Updated. Y= 745.1388888888887 <-- glitch. With or without the glitch happening, the sprite is always created in the right position and is affected properly by gravity the first to updates. When the glitch happens it happens always on the third update. This is body.blocked on each update when the glitch happens: Object {up: false, down: false, left: false, right: false} Game.js:116Object {up: true, down: true, left: false, right: false} Game.js:116 <-- everything should be false here!Object {up: false, down: false, left: false, right: false} Game.js:116Object {up: false, down: false, left: false, right: false} Game.js:116 After setting body.collideWorldBounds to false the glitch never happened again. Maybe the game is skipping a few frames at the beginning and the sprite falls through the ground and collides with the world bounds, but in that case when body.collideWorldBounds is set to false I should sometimes see fall out of the world fater the first two updates, and it never happens. It also never happened with previous versions of Phaser, but I have no idea what could be causing this. [uPDATE 2:]commit 98e6f155deb54727c8b4769632bd416ee5758ab1 build/phaser.js: no glitchcommit 88eae3aed079d628e7eddfbf2b46299ee0fc9564 build/phaser.js: glitchI haven't tried building all the commits in between but I noticed you refactored physics calculations on a0cc4c3777f37b51cc77f1051c998ec1b9e76913 Link to comment Share on other sites More sharing options...
stupot Posted November 10, 2014 Share Posted November 10, 2014 No problems or issues with RC1 in my app, but a few comments. - would be helpful if this reported itself in the console specificaly as 2.2.0-RC1 instead of 2.2.0-dev which is the usual name for a non-specific version of many iterations between releases. - the effect of the new fixed-step timer is noticable. I already has some local time compensation for some objects which needed to keep up with real time whilst others were allowed to lag but remain smooth. Is the new timer able to revert back to the old behaviour if desired and on a per object basis? Link to comment Share on other sites More sharing options...
JUL Posted November 10, 2014 Share Posted November 10, 2014 Well, too much things going weird for me on my current game, so I'll stick to 2.0.7 which is basically (as I perceive it while using it) 2.0.5 with working retro fonts. As in the 2 previous version prior to this one, retro fonts tend to get weird, like if the new assigned text was pasted on top of the previous one without erasing it.Like if some kind of clear call was required before modification. Velocity.y on jumps results in mega jumps sometimes, don't know why."Elasped time" doesn't seem to be linear, "push start" message flickering on intro screen not always flickering in a linear manner after 15 seconds or so.map.getTileWorldXY not returning something at the very begining of the Level like it used to. For now that's all I've noticed on my current project. Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 Noid: Can you try this please: when you log out the y position and that glitch, can you also log the game dimensions (game.width / height) because I'm wondering if actually it's hitting some weirdly resized game bounds, which is why the collide call fixed it. I.e. it's hit a world bounds that has resized momentarily, screwing things about. Which might be a result of the new ScaleManager code rather than the time step. Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 stupot - I've updated the console version to RC1, good idea. There is no way to disable the time step on a single object, it has to be an "all or nothing" case or it won't work properly. JUL - I would never expect a jump from 2.0.7 to 2.2 to be smooth, so none of this surprises me really, far too many changes since 2.0.7 which means it could be anything causing them. The RetroFonts issues should be reported on github please (as I've never seen it happen, so wouldn't know to fix it) - it does sound like a simple issue though. Link to comment Share on other sites More sharing options...
valueerror Posted November 10, 2014 Share Posted November 10, 2014 no problems at all with my current game.. switched form 2.1 to 2.2 Link to comment Share on other sites More sharing options...
Noid Posted November 10, 2014 Share Posted November 10, 2014 @rich: It outputs the correct value on every update, glitching or not (800x600). I thought it had something to do with skipping frames because it happens much more often in Firefox. Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 Fair enough - that's a very dramatic shift though, that isn't just a skipped frame or two. Link to comment Share on other sites More sharing options...
valueerror Posted November 10, 2014 Share Posted November 10, 2014 this is the most awesome new feature game.time.desiredFps = 50;finally framedrops don't affect the gameplay anymore. thank you so much Link to comment Share on other sites More sharing options...
Hsaka Posted November 10, 2014 Share Posted November 10, 2014 Dropped in the 2.2.0 build files into All Fours Online (http://gamepyong.com/allfours_online/html5) and it worked perfectly. I just had to make sure that all of my buttons used spritesheets instead of images otherwise I'd get this: Uncaught TypeError: Cannot read property '_uvs' of undefined This game is using 2.0.7 currently so I was happy to see that jumping to 2.2.0 didn't require any changes except for the one above.I also tried compiling it with CocoonJS and got no issues. Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 @Hsaka - probably the best news I've had all day, thanks Would like to try and resolve that button _uvs issue though, you got a tiny bit of code I can replicate it with at all? Link to comment Share on other sites More sharing options...
Hsaka Posted November 10, 2014 Share Posted November 10, 2014 Hey Rich, you can see it here: http://gamepyong.com/demo/phaser/On posting this, I realized that I'm doing a stupid thing by including the over, out and down parameters; I should've just left them out and there would be no issue. Link to comment Share on other sites More sharing options...
Serapth Posted November 10, 2014 Share Posted November 10, 2014 Greatest new feature ever! No I don't even have to care about performance, just set my code to game.time.desiredFps = 60 and I'm golden! /just kidding. Nice new feature, I'll try with all the various tutorial samples I've done and see if anything breaks. Link to comment Share on other sites More sharing options...
lukaMis Posted November 10, 2014 Share Posted November 10, 2014 When i change from Phaser v2.1.3 to Phaser v2.2.0 scale.pageAlignHorizontally stops working. Game is just at left edge of browser. I am using this code:this.scale.scaleMode = Phaser.ScaleManager.SHOW_ALL;console.log("this.scale.pageAlignHorizontally", this.scale.pageAlignHorizontally);this.scale.pageAlignHorizontally = true;console.log("this.scale.pageAlignHorizontally", this.scale.pageAlignHorizontally); I get true in console for second (this.scale.pageAlignHorizontally) but game is at left edge. Link to comment Share on other sites More sharing options...
valueerror Posted November 10, 2014 Share Posted November 10, 2014 @serapth.. you know i'm tuning my code for performance for ..like forever now.. still the most awesome new feature here Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 @lukaMis - it's working ok here, but I suspect it's more to do with how the page has been set-up. Is your game going into another div, browser window, etc? Link to comment Share on other sites More sharing options...
lukaMis Posted November 10, 2014 Share Posted November 10, 2014 @richI find it weird that it changes alignment if i change engine version. wellhtml is:<style>body {padding: 0;margin: 0;background-color: #6f9ece;}.wrapper {position: fixed; top: 20px; /*bottom: 0px;*/}</style><body><div class="wrapper"> <div id="gameContainer"></div> </div> <script type="text/javascript"> window.onload = function () { var game = new Phaser.Game(890, 500, Phaser.CANVAS, "gameContainer"); game.state.add("Boot", ParkingHouse.Boot); game.state.add("Preloader", ParkingHouse.Preloader); game.state.add("MainMenu", ParkingHouse.MainMenu); game.state.add("Game", ParkingHouse.Game); game.state.start("Boot"); };</script></body>Here is link Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 Given how drastically the ScaleManager has changed, it's really not that weird I'll test your html with the dev build. lukaMis 1 Link to comment Share on other sites More sharing options...
rich Posted November 10, 2014 Author Share Posted November 10, 2014 @JUL - Here: https://github.com/GoodBoyDigital/pixi.js/issues/1147 sound familiar? Link to comment Share on other sites More sharing options...
fariazz Posted November 11, 2014 Share Posted November 11, 2014 All these new features sound excellent! will be happy to test. Tried it with my sidescroller demo and the player now goes through the tiles :s http://static.pablofarias.com/sidescroller-22/ This was with the previous version: http://static.pablofarias.com/sidescroller/ Link to comment Share on other sites More sharing options...
rich Posted November 11, 2014 Author Share Posted November 11, 2014 fariazz - the character didn't go through the tiles once for me (played it several times over) Link to comment Share on other sites More sharing options...
rich Posted November 11, 2014 Author Share Posted November 11, 2014 Ok Release Candidate 2 is now uploaded. I've merged in the latest Pixi dev version, which should fix errors like RetroFonts not clearing properly in canvas mode and some Graphics class fixes. There are also some more tweaks and fixes which you can find in the README and a couple of features that I've been meaning to add for ages (Tilemap.createFromTiles being one of them) Link to comment Share on other sites More sharing options...
Serapth Posted November 11, 2014 Share Posted November 11, 2014 All these new features sound excellent! will be happy to test.Tried it with my sidescroller demo and the player now goes through the tiles :s http://static.pablofarias.com/sidescroller-22/This was with the previous version: http://static.pablofarias.com/sidescroller/By the way, the first link is seriously broken on iOS, second works fine. So might want to do some Safari testing if you haven't already. Link to comment Share on other sites More sharing options...
Recommended Posts