I put max number of hp to 5
1 layout > hp decreased to 3
when the cat runs to another layout the hp should be still at 3, but it comes back to 5
Instance variable will reset when instance is created on start of layout. You can make it 'Persist'. Or you can use a global variable for HP which is usual and remains the same across layouts.
interesting... how to make it persist?
Develop games in your browser. Powerful, performant & highly capable.
Probably better not to use persist behaviour on the player, although you can make him global in properties. Easiest way though is to make the hp a global variable, you can change it and it keeps its state between layouts!
global... are they those green things? should I copy paste them to the other layout?
No you just need them somewhere in the project and it's fine. You replaced the instance variable on player with the global so it should be working now?
ooh ohh this event gone after i deleted instance variable
i was using instance variable or this event. can i replace that compare instance variable?
this is instance variable on text
so now i did it.... the hp number keep continuing last number from prev layout. the next problem is... i have deleted an instance variable which trigger another event. i changed it to text2's variable (food/hp) but it cannot trigger the other events (disable platform, visible popup, etc)
You didn't need to delete the instance variable though...revert those changes if you can so you return to your normal events. Replace the instance variable food with the global variable in events as you go.
how can i replace with global ? this event, that attached to instance variable, how to make it using global variable?
Replace it with system > compare global variable, with the same info. You can add it somewhere else first and drag it under it then delete the old one. Or press C, add it as a condition and delete the old one after.
is it like this? nothing is happen... or maybe i should delete unnecessary event.... but which one ' ')
Yeah that is correct but you also need to update the actions where you subtract food. You need to replace all use of the instance variable with the global variable.