md_lasalle Posted October 18, 2017 Share Posted October 18, 2017 Hey guys, I was profiling my game and it seems like I could save some cpu time if I could bypass this function call in my objects' postUpdate : postUpdate: function() { ... if (this.components.PhysicsBody) { Phaser.Component.PhysicsBody.postUpdate.call(this); } ... } My question is, since my game doesn't use any physics at all, do I have to rebuild phaser without physic support? Or is there a simpler way to simply disable the creation of physics body on all my game objects? Thanks for any input! Link to comment Share on other sites More sharing options...
samme Posted October 18, 2017 Share Posted October 18, 2017 All sprites have the PhysicsBody component, but they don't have a physics body unless you add one. PhysicsBody.postUpdate just exits if there's no physics body, so it's unlikely a lot of time is spent there. Link to comment Share on other sites More sharing options...
md_lasalle Posted October 18, 2017 Author Share Posted October 18, 2017 Still spending more time than I'd like (I use a LOT of groups) samme 1 Link to comment Share on other sites More sharing options...
samme Posted October 18, 2017 Share Posted October 18, 2017 Phaser.Sprite.prototype.components.PhysicsBody = false; md_lasalle 1 Link to comment Share on other sites More sharing options...
md_lasalle Posted October 18, 2017 Author Share Posted October 18, 2017 Thanks Sammy, my frame time spent on scripting and rendering is now below 4ms, extremely smooth 60fps was my target, and you helped me get there. Also just throwing it out there, I discovered that accessing the width/height property of a group/sprite was causing an updateTransform call every time! Caching this value was one of the biggest gain I got. Link to comment Share on other sites More sharing options...
Recommended Posts