Flexicon Posted March 30, 2014 Share Posted March 30, 2014 So I have a little game concept I've been making in phaser and I have the parts of it split into states such as main menu and levels, but what I have been doing is creating the Player objects and enemy objects and the such in each individual states as well as making animations for them. This is very obviously inefficient I want to know how would I go about making an object for these entities to use it cross states Link to comment Share on other sites More sharing options...
Martiny Posted March 30, 2014 Share Posted March 30, 2014 I don't know if I fully understood, but have you tried creating them outside any state? You could create a player.js or enemy.js and adding it into your http requests, without being inside any state itself. Then it should be available for all states, if I'm not mistaken. Link to comment Share on other sites More sharing options...
Flexicon Posted March 30, 2014 Author Share Posted March 30, 2014 Yeah thanks for replying!After I posted I thought of doing something like that. Only thing is I'm not quite sure how I would go about including the entity in a new state. I suppose I would make a var in the state equaling to the player object. I suppose the thing I'm looking for would be doing something along the lines of creating a new instance of a Player class. Just not sure how to achieve this right now xD Link to comment Share on other sites More sharing options...
Recommended Posts