Jump to content

Change state in html?


Pietari
 Share

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))
    {
        this.game.state.start("Room");
    }

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

4 hours ago, Pietari said:

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

I'm not sure what you're asking here. You want to reload a different page entirely? A completely separate game?

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

 Share

  • Recently Browsing   0 members

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