Cant keep a light on between layouts

0 favourites
  • 9 posts
From the Asset Store
Immerse your quiz games with our 6 unique music loops, ranging from acoustic chill guitar to cute and upbeat style.
  • Howdy

    First time posting here, I came across construct over at steam and gave it a go and so far its going ok.

    I have spent a lot of time reading this forum and thanks to some of you guys you have fixed issues for me without even knowing it.

    So on to the problem. by the way I haven't programmed anything in my life.

    I have a game where the player can go back and forth between a layout, I have managed to do this and set it up with web storage so it saves your location so when you teleport back your in the same place.

    (this will also act as a save point)

    But I am having trouble with one aspect.

    In the game there are lamps on the wall you can light and that's fine I can happily turn them off and on but I want to have it so if you light one and then go to the other layout and come back it remembers that it was a light.

    I have been trying to do this with a global vars I have been setting it so if you press it, it sets 1 to a var and that makes it play the on animation and when you press it again it turns it off subtracting the var

    I have then set this var to web storage on the teleport between layouts so it remembers the var but every time I come back the light is always off.

    Im not sure what else to try.

    Any help would be great

    dropbox.com/s/p2cayngv5ojvn5i/ideatest.capx

  • ON the start of the layout are you reading back in the items from the webstorage and setting the lights back to on, etc... based on the info? I can't open the capx as I am at work, but that was my first thought...

  • Howdy thanks for replying.

    Yeah on the start of layout im calling the web storage bits which in theory should hold the val of the lamp and then if its 1 it should set the animation to light, or thats how I figured it out in my head anyway.

    But it just does not want to do it so im thinking I must be doing something wrong somewhere.

  • To test, you may want to have a text object on the screen and set it to the value being pulled from web storage. That way you can see if web storage is getting you what you need. If it is, then the issue is with the logic that should be assigning that value to the variables, or lighting the light based on them.

  • Bleh... edited as that was the response to a different question.... looking at your capx now to see what the issue may be...

  • Looks like your not actually doing anything on the start of layout to turn the flame back on. You are setting the variable, but the only things I can see that actually set it to on have conditions that say if E is pressed, and overlapping, etc... there is no event to set the flame to the on animation etc... on start of layout if the flame variable is set to 1. I am adding an event for it now, but you will have to tweak to get what you want. Just setting the variable to 1 doesn't turn the flames on because you don't have any logic anywhere that says if flame = 1 turn on the torch.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ahhhh I knew I was going wrong somewhere but thank you so much for the help. If I could hand you as cookie I would

  • Here you go: dl.dropbox.com/u/138635871/ideatestNEW.capx

    YOu will need to do a couple of things though.

    • You need a variable to keep track of witch torches are lit
    • You need to create an event to check the value of flame and set the correct torches to be lit (Turn on collisions, start the "On" animation, etc...)
    • Right now your only logic for turning them on is if they are overlapping when you hit E. YOu need logic for turning them on when the layout starts as well.

    I provided a simple event that turns them on when the flame variable is set to 1, the issue with that is that all of them turn on at once. You need to implement some logic using the UID or IID of the objects so you can tell which ones are lit and which ones are not. You then need to store that info so that when you load the layout, you can load a list of which ones are supposed to be lit, and start their animation playing as well as setting the collision on or off as needed.

    Hope this helps...

    On a side note, you really need to start naming your sprites as it took me most of the time just to figure out what each event was connected to...

  • Awesome many thanks.

    Have had a look and it does make sense, ok then its time to get my head around IDs then, which should be fun.

    Sorry about the mess with naming all the sprites are placeholders at the moment and to be honest I didn't think Id get anything to work.

    So ive kinda just threw everything in there and try to test it out but I will rename things to make it more cleaner.

    Many thanks again.

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