Create a score that doesn't reset on new layout

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

    I'm figuring out Construct 2 and really like it and bought the license. Now I'm practicing with a platform demo.

    I created a score on the platform but when I'm going to the next layout it sets to zero. I tried multiple things and I don't understand why it resets. Also tried using webstorage but I don't seem to figure it out yet.

    I read multiple tutorials and searched the net for the problem but still can't find a solution.

    Uploaded my capx as rar here http://surreal3d.nl/capx/platformdemo.rar

    Hope you can help :)

    Sander

  • Hi Surrealizer,

    Welcome to C2, glad you're enjoying it so far!

    I just took a look at your capx, and you are using local variables for score, health etc. It would be better to use global variable, as these can be used anywhere even across different layouts.

    To add a global variable just right click on the event sheet, then scroll down to 'add global variable'. And don't forget to change your code, so that you're adding score, health etc, to your new global variables.

    Hope that helps :)

  • Hi Blacksmith

    Thanks for your reply! I guess you're right, I thought I already had global variables because global was set on yes on the left.

    I changed it like you said and it's fixed! Thank you so much for your help! <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Hey Surrealizer,

    No problem, glad I could help. And don't worry, it does take a little while to get used to a new environment, and a new way of doing stuff. Keep at it, and you'll be an old-pro in no time ;)

  • Blacksmith

    Didn't want to start another topic so maybe you know the solution? I got a ground enemy which I want to have health. I used a local (health) variable. It's working but because of a wait function (so you can see a dying animation before it's destroyed) the (global) kill score adds like 12 points instead of 1. I don't understand why this happens because it doesn't happen to enemies without health (with wait function).

    http://surreal3d.nl/capx/platform_groundenemy.rar

    http://surreal3d.nl/capx/platform_groundenemy.capx

  • It is because of the wait action.

    During the time that it is waiting, the condition is still true and the actions are still being registered (as explained in this tutorial).

    Make a new event Enemy: On destroyed and have your action "Add 1 to kill" in it. This way, the addition will only happen once, and only once the object is actually getting destroyed.

  • Try Construct 3

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

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

    Thank you very much the problem is solved.<img src="smileys/smiley1.gif" border="0" align="middle" />

    I thought it would be something like that but somehow it didn't happen to the enemy without health.   

    Thanks for the info I will check out the tutorial!

  • Hey Surrealizer,

    Ah, I've just been testing your example and putting together a reply, but I guess it's not needed now!

    Glad you found an answer though (thanks Kyatric).

    Good luck with the rest of your project :)

  • Hey Blacksmith

    Yes it's solved. Thanks for your time and effort!

    I will it's great working with construct. Always want to figure things out myself but when I can't understand the logic of something not working I have to ask after a couple of hours/days...

    I'm amazed how helpful this forum/community is <img src="smileys/smiley4.gif" border="0" align="middle" />

  • Surrealizer,

    Yeah, the C2 community is really great if you need help! So much knowledge, and they are always happy to share it :)

    I've had plenty of help myself since I started, and I'm sure I'll have plenty more questions to ask in the future. After all, there's always something new to learn ;)

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