How do I create an advanced checkpoint

0 favourites
  • 8 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hello

    I'm trying to make a checkpoint that changes its animation whenever that checkpoint is active, which means if you would have two checkpoints near, you could tell by an animation which one is activated for the loading data.

    Now the problem is, how can I trigger this? I'm basically using the save/load function built in C2, when player collides with the checkpoint saves the game. On dead load from save.

    If I were to have three checkpoints how can I make one of them to change its animation to "Active" based on the save/load.

    Thanks

  • Here is an idea: make a global variable that saves the UID of the checkpoint you reach. I am pretty sure that global variables don't reset when the layout restarts or loads. That way, you can say which one you want to change the animation of.

  • Here is an idea: make a global variable that saves the UID of the checkpoint you reach. I am pretty sure that global variables don't reset when the layout restarts or loads. That way, you can say which one you want to change the animation of.

    Global variable was my idea but I dont really know how to make it work

  • Smileh,

    I don't know if the UID of the object would work or not but I would add an instance variable to the checkpoint object. You can then give every checkpoint a unique ID (Value) which will be put inside the instance variable.

    When the player reaches a checkpoint, you can save the instance variable of that checkpoint in localstorage or simply with the built in save/load function.

    Then you just add a condition which checks every single checkpoint if it contains the saved value. If it's the same, that should be the last checkpoint and you can change its animation to active. Every other checkpoint can be set to the inactive animation.

    I hope this helps!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Smileh,

    I don't know if the UID of the object would work or not but I would add an instance variable to the checkpoint object. You can then give every checkpoint a unique ID (Value) which will be put inside the instance variable.

    When the player reaches a checkpoint, you can save the instance variable of that checkpoint in localstorage or simply with the built in save/load function.

    Then you just add a condition which checks every single checkpoint if it contains the saved value. If it's the same, that should be the last checkpoint and you can change its animation to active. Every other checkpoint can be set to the inactive animation.

    I hope this helps!

    Can I do this with the save/load function as well? I have no idea how to datastorage

  • Yes you can use the save function aswell. You just have to set the instance variable (or animation frame <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">) of the object and then save the whole game state.

    If you use the save/load function you don't need to do that though, because it will save the whole state of the game.

    Here is an example capx with a working waypoint system:

    https://drive.google.com/file/d/0B7r2WY ... sp=sharing

    In my example you actually don't even need to use an instance variable. I just used the animation frame of the object (You can have an activated animation frame and a deactivated one). 0 is deactivated and 1 is activated.

    I hope this helps! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

  • Yes you can use the save function aswell. You just have to set the instance variable (or animation frame <img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile">) of the object and then save the whole game state.

    If you use the save/load function you don't need to do that though, because it will save the whole state of the game.

    Here is an example capx with a working waypoint system:

    https://drive.google.com/file/d/0B7r2WY ... sp=sharing

    In my example you actually don't even need to use an instance variable. I just used the animation frame of the object (You can have an activated animation frame and a deactivated one). 0 is deactivated and 1 is activated.

    I hope this helps! <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">

    Thank a lot for the example. I heard pick nearest can cause performance issues, can I use a variable instead? I feel stupid. I figured out harder things and now simpler stuff confuses me lol

  • You could probably use the For each loop to check every checkpoint if it is touching the player. If that is true just set the animation frame of that checkpoint to 1 (active).

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)