Jump to content

OOP for this or not?


Recommended Posts

So, I want to create a menu for displaying the controls to my game - I will be using multiple variables, inevitably, for each control explanation. This will likely take the form of at least 5-7 variables, so instead of writing a variable out multiple times to achieve this, would constructing a new object per "explanation" be more efficient as I will have to pass this.game.world.CenterX for each one, as well as its position and its font colour, so I didn't know if it would be more efficient using OOP or not? If it would be, how could I achieve this? The heading.anchor.set part will remain the same for all "explanations", hence why I am considering implementing a more efficient way of achieving this. If I have misunderstood/misconstrued the usefulness of OOP in this, then please just say as I am still learning Phaser and OOP so I am unsure as to whether what I want to do could be done more efficiently or not.


ControlMenuState = {};
x = 480;
y = 300;
ControlMenuState.create = function () {
  this.game.stage.backgroundColor = '#6d94b5';
  var heading = this.game.add.text(this.game.world.centerX, 100, 'Controls...', {fill: 'white'});
  heading.anchor.set(0.5, 0.5);



Link to comment
Share on other sites


  • Recently Browsing   0 members

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