Jump to content

Witch OOP Phaser choose? Witch makes the run faster?


Salvatore
 Share

Recommended Posts

Hi there little felas,

 

I stumbled upon two ways to code with Phaser in OOP. Each one are diferent in how to code, and in how to structure your game.

 

The first is the familiar http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-1/

Let's call it "flappy tutorial".

 

And the second is the http://createdineden.com/blog/2014/may/01/multi-platform-games-with-phaserjs/

And this we call it "not-flappy tutorial".

 

Well, the flappy tutorial uses a simple and easy to understand way to structure the game. He uses the objects/classes ass a simple module of code to be added to the main code, without any complication and any work to think about.

 

In the not-flappy tutorial, I took a few seconds to understand how it works. He makes the object a extention of the Phaser.Sprite to determinate that object ass a sprite, and to add to the game, you have to add ass a existing object through Phaser.Game.add.existing and add the object ass a Phaser object.

Cool huh?

 

So, witch one of these ways make our game run smoothly? Take less time to execute?

 

May the force be with us, so we can live long and prosper...

Link to comment
Share on other sites

I'd probably go out on a limb here and say that coding style in the broadest sense won't make an appreciable impact on performance, as at the end of the day most of the heavy lifting is done in Phaser's update loops. What will matter is what you do in the update loops, and whether you use optimisation methods such as object pooling, culling and so on. It's not really as simple as adopting a certain type of faux-OO JS pattern.

Link to comment
Share on other sites

Phaser.GameObjectFactory as it stands only serves as a convenient way of creating new instances of objects; it doesn't offer any performance advantages (that I'm aware of) over manually creating sprites via new Phaser.Sprite. Extending the Phaser.Sprite object doesn't change the performance vs a normal sprite either until you start adding in your own routines, and then it's totally dependent on the optimisation of the routines, rather than as a result of the fact that it's extended.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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