How to set layout according to url hash (#) at first load?

0 favourites
  • 1 posts
From the Asset Store
A whole set you need to create a gorgeous winter 2d game
  • Hi, this is my first post so I'd like to start by saying thank you to everyone who is involved in creating and maintaining this great piece of software.

    I am trying to create a plugin that allows the app/game to navigate to a layout according to whats after the hash sign in the address (#), like:

    example.com/#MyLayout

    example.com/#MyOtherLayout

    That way you can access different parts of the game by url, so you can use the navigator arrows, history, bookmarks, etc... I think that way you could actually make really beautiful and modern websites in Construct.

    I searched for something like that but didn't find anything (please correct me if I am blind and there's already something like this). Anyway, the way I am doing it, it is a very basic plugin (based on Ben Alman's hashchange jQuery plugin) and it is almost done: I can add the (global) object to my project and when I load the game in the browser and start changing the address, introducing the exact name of the layout after the hash (like #MyLayout) it correctly navigates to the layout. However, there is one thing that's driving me crazy:

    How do I cause the game to go to a certain layout, from the runtime, when it first loads?

    That's needed so that you can access specific parts of the game by address, like when you share a link. The most obvious approach was to set runtime.changelayout at instanceProto.onCreate but that didn't work. I also created a callback for the document load but that didn't work either.

    If anyone has an answer to my question (in bold above) it will be very much appreciated. Once the plugin is done I would like to share it with everyone.

    Thanks.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)