Jump to content

Which programming pattern is more appropriate?


yltang
 Share

Recommended Posts

I am new to Phaser and I am going to teach a "game programming" course in a college. I noticed that there are two programming patterns as follows:

 

/* Pattern A ------------- */
var game = new Phaser.Game(..., {preload: preload, create: create, update: update});

function preload() {
}
function create() {
}
function update() {
}

/* Pattern B ------------- */
var game = new Phaser.Game(...);

var mainState = {
  preload: function() {
  },
  create: function() {
  },
  update: function() {
  },
};
game.state.add('mainState', mainState);
game.state.start('mainState');

 

/* ------------- */

 

I wonder which one is better? Also, I have three strategies:

a. Always use Pattern A.

b. Start from Pattern A, and then switch to Pattern B as the game becomes more complex.

c. Always use Pattern B.

 

Any suggestion? Especially, for the purpose of teaching/education.

 

BTW, is it possible to always use Pattern A; no matter how complex the game is?

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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