Jump to content

Phaser 2.2.0 Release Candidate 11 - Please Test!


rich
 Share

Recommended Posts

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 desiredFps
  • Time.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 independently
  • Switching between fullscreen and normal correctly restores modes
  • Alignment does not incorrectly offset in fullscreen mode (#1255)
  • Changing scale/alignment promptly refreshes layout
  • isFullScreen returns a boolean, as it should
  • Faster 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

Link to comment
Share on other sites

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:80
Updated. Y= 2510 Game.js:115
Updated. Y= 2510.1388888888887 Game.js:115
Updated. Y= 2510.4166666666665 Game.js:115
Updated. Y= 2510.833333333333 Game.js:115
Updated. Y= 2511.3888888888887 Game.js:115
Updated. Y= 2512.083333333333 Game.js:115
Updated. Y= 2512.9166666666665 Game.js:115
Updated. Y= 2513.8888888888887 

 

Glitch: 

 

created. Y= 2510 Game.js:80
Updated. Y= 2510 Game.js:115
Updated. Y= 2510.1388888888887 Game.js:115
Updated. 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:116
Object {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:116
Object {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 glitch

commit 88eae3aed079d628e7eddfbf2b46299ee0fc9564 build/phaser.js: glitch

I 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

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

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

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

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

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

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

@rich
I find it weird that it changes alignment if i change engine version. :)

well

html 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

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

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

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...