Jump to content

Change state in html?


Recommended Posts

I am new to states and don't really understand them. What i would like to do is to change the state when player is colliding with door. Do the states need to be javascript? Or can i just make them in HTML and have <script> tags?

Well anyway this is what i would like to do: 

 if (checkOverlap(door, player))

Do i have to make the states in javascript and have an index.html where all the states are added?

I tought it would be easier to have it just load Room.html.


Link to comment
Share on other sites

29 minutes ago, drhayes said:

You're confusing creating a file in HTML and writing code in JavaScript. A state is a JavaScript object that you create and then tell Phaser about. You can make all the states in one file if you want, the code doesn't care. ( =

But can i have something like states as html? Like i would just like my code to change the code it is running.

Link to comment
Share on other sites

So you're basically trying to "teleport" a player to another level or map right?

If that's what you're trying to do, don't compare websites to a game engine. You're dealing with a canvas element that does everything in your game. You will need to program your game so that when you want to teleport the player to another map, you need to redraw the whole scene/world with the new stuff found in your next map. You can keep the information in a static file like a .json file and read it from there.

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.

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.


  • Recently Browsing   0 members

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