Hello.
I have problems with the instance variables, and the behaviour-functions not working as expected after restarting a Layout.
Before I get into the depth explaining my problems I gladly accept all suggestion of 'what to think of when restarting a Layout.' If you like me have built a Level in a game that needs get restarted for the player to start from it's original starting point.
...
What I have done is that I have made a Level on a layout. If the player gets killed he needs to start over from his original starting point. The reason I need to restart the layout is that I have made a kind of system, a kind of editor in Construct, where I've placed different objects (Sprites) on the layout to build the level. The sprites (lets call them spawning-sprites) spawn different things, like... Enemies, and Towers. The spawning-sprites gives different properties to the Enemies and so on. To do so the spawning-sprites uses it's instance variables and sets the thing that gets spawned - it's own instance-variables.
I hope you follow me so far.
To sum up. I've made a level on the Layout, placing out all the stuff and mobs - setting their properties.
To explain more about the mechanics...
When a spawning-sprite Is On Screen, they spawn for example an Enemy. Sets their amount of Ammo, their bulletspeed, the attackspeed, range, points, their state, what animation to use, and so on. All this comes from instance variables from the spawning-sprite.
Some things sets the Enemy's own instance variables, and other things that are set are different behaviour properties, like Range for the LOS behaviour.
Its HERE i get problems.
The reason I've done this is that By placing a spawning-sprite. I can trigger a function that spawn an entire wave of enemies, making them move in patterns and so on. The enemies uses the spawning-sprite for different things. For example uses it's image-points to move in different patterns. I've also made a figure (picture) showing the way the enemy should move. This way I've made a kind of pool, with spawning-sprites that makes the enemy do different things. I can then Place them in a nice way in Construct building up my level. And the benefits are that I can see in Construct roughly how the level should look like and this way I can use the Layouts to make different levels, using the same components, just setting them up differently.
If I preview the game from Construct. Everything runs perfectly. The player spawns at the right place, the screen moves to the player. All stuff at the map spawns, and they have the right properties and do the right things.
However, if I get killed, and are supposed to start from the beginning. ( I restart the layout.) The stuff on the map does not perform as they are meant to.
When I run the game in Debug-Layout-mode I try to find the problems. But all the instance-variables for the different objects seems fine. I cant find the problem.
For example. If an Enemy has more than 0 ammo ( ammo > 0 ). The enemy are in range to the player, enemy has Line Of Sight. And finally are the right "Type" they should fire at the Player.
They do not do so? Even though when I check the variables, and other properties for the enemy at the debug-layout. And all things are set correctly.
I have not used a single global or local variable in the game.
I also, the global property you can set for Sprites. They are not set to "global", except for one. That only one are the Score-Sprite, with 2 instance variables: Score and Lifes.
In the Construct manual. it says:
[quote:2fn4j75h]Restart layout
Restart the current layout. Note that unlike Go to layout, this action resets all event groups to their initial activation state. Global variables keep their current value - they are not reset. To reset them use the system action Reset global variables.
I'm not sure how to interpret this. If it means all variables, instance or not, get reset unless they are Global?
Right now, it feels like it's something with the LOS-behaviour. It feels like even though the enemy are in range, the LOS cant sense it? It could be the cone-of-view or the range. I dont know.
I'm working on placing some sprites as indicators, to see visually how far the range are, and how the cone of view are set.
Enough of explaining.
Anyhow, I appreciate any input you can have about what you think could solve this problem.
Thanks.
///Soulmachine!