Jump to content

2 questions about phaser


pranadevil
 Share

Recommended Posts

Most of the browsers have perf tools built into them. I know that at least Firefox and Chrome do. You can see docs for them Firefox here and Chrome here. Safari has some tools as well, but I don't remember if they are built in or are a standalone app. Regardless, it's Mac only (but so is Safari, so...)

When you pass the parameters into a tween function, you're actually passing an object. It goes through the keys of the object and uses those as the properties to modify. So if I wanted to change both the X and the Y position I would do it like so:
 

game.add.tween(sprite).to( { x:newXValue, y:newYValue }, 4000, Phaser.Easing.Bounce.Out, true);

You can pass in as many different properties as you want at once. The one caveat would be if you wanted to change something like position and scale, because scale values are stored as a Phaser.Point value (named 'scale'). In a case like that, you can just start two tweens at the same time. So if I wanted to change my X position and my X scale at the same time, it would look something like:

game.add.tween(sprite).to( { x:newXPositionValue }, 4000, Phaser.Easing.Bounce.Out, true);
game.add.tween(sprite.scale).to( { x:newXScaleValue}, 4000, Phaser.Easing.Bounce.Out, true);


 

Link to comment
Share on other sites

Not sure what performance metrics you are concerned with. If it is simply fps, a common Phaser approach is to set game.time.advancedTiming = true. You can then check the game.time.fps property and write that to the screen using game.debug.text() in your render loop. Beyond that I find this little tool from Mr. Doob to be very helpful. https://github.com/mrdoob/stats.js/ The bottom of the readme has a simple bookmarklet approach, whereby you can add this as a bookmark in your browser and enable it as needed without needing to modify existing code or depend on any framework specific functionality.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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