Sign in to follow this  
Flexicon

Player/Enemy objects for cross states

Recommended Posts

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 :)

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.