Problem with spawning
philm
Member Posts: 8
Hi, really hope someone can help me with this, presume I'm overlooking something obvious.
I have 4 actors :
Controller
button_open_window_a
window_a
close_window_a
I have an integer game variable, 'gss' initialized to 100.
What I want to do:
Initially there is only an (invisible) instance of 'Controller' on the screen. I want this to spawn 'button_open_window_a'.
When I press 'button_open_window_a' I want to spawn 'window_a' and destroy 'button_open_window_a'.
Upon spawning 'window_a' I want 'close_window_a' to be opened on top of it.
If 'close_window_a' is touched I want 'close_window_a' and 'window_a' to be destroyed and 'button_open_window_a' to be spawned.
Essentially, I want to use a button to open a window (which has a close button on it), when the window is open the 'launching' button dies. When the window is closed (using its close button) the launch button reappears.
Everything works as expected except the 'button_open_window_a' doesn't reappear when the window is closed, HOWEVER the code on the Controller DOES GET CALLED!! It just seems to ignore the command!
Why am I doing it this way? I'm going to have lots of problems with the 'click through' behaviour in GS where clicking on the screen clicks everything under it (multiple layers). So instead, I'm deleting what has gone before. This will not get over-complicated as my program isn't too complex.
What I've done:
Controller : RULE: if gss = 100 then set gss = 200 and spawn 'button_open_window_a'
button_open_window_a : RULE: if gss > 200 then destroy
RULE: if touched set gss = 300 and spawn 'window_a'
window_a : RULE: spawn 'close_window_a'
RULE: if gss != 300 then destroy
close_window_a : RULE: if != 300 then destroy
RULE: when touched is pressed set gss = 100
I have 4 actors :
Controller
button_open_window_a
window_a
close_window_a
I have an integer game variable, 'gss' initialized to 100.
What I want to do:
Initially there is only an (invisible) instance of 'Controller' on the screen. I want this to spawn 'button_open_window_a'.
When I press 'button_open_window_a' I want to spawn 'window_a' and destroy 'button_open_window_a'.
Upon spawning 'window_a' I want 'close_window_a' to be opened on top of it.
If 'close_window_a' is touched I want 'close_window_a' and 'window_a' to be destroyed and 'button_open_window_a' to be spawned.
Essentially, I want to use a button to open a window (which has a close button on it), when the window is open the 'launching' button dies. When the window is closed (using its close button) the launch button reappears.
Everything works as expected except the 'button_open_window_a' doesn't reappear when the window is closed, HOWEVER the code on the Controller DOES GET CALLED!! It just seems to ignore the command!
Why am I doing it this way? I'm going to have lots of problems with the 'click through' behaviour in GS where clicking on the screen clicks everything under it (multiple layers). So instead, I'm deleting what has gone before. This will not get over-complicated as my program isn't too complex.
What I've done:
Controller : RULE: if gss = 100 then set gss = 200 and spawn 'button_open_window_a'
button_open_window_a : RULE: if gss > 200 then destroy
RULE: if touched set gss = 300 and spawn 'window_a'
window_a : RULE: spawn 'close_window_a'
RULE: if gss != 300 then destroy
close_window_a : RULE: if != 300 then destroy
RULE: when touched is pressed set gss = 100
Comments
If it turns out that this is the issue, you could put a small timer on your controller to make it wait, say 0.15 seconds before spawning the button.
If you can't change the function of the button with a combination of rules like a combined replay and next button, try moving them off the screen by changing their self.Position.X or Y. Once pressed it can not be accessed again by the player until your condition/s change.
Universal Binary Template - Universal Binary Template Instructions Rev 4 (Short) - Custom Score Display Template
Yes Socks, if you think of how windows close in Windows. I don't want the window to close unless I specifically click on its 'close button' (diff actor).
Hi Bryan, I moved the 'set gss=200' to after the spawn but didn't make a difference.
I've created this tiny program purely for debugging purposes to resolve the issue that is appearing in my main program, the problem that I'm having at present isn't a click-thru issue (because there are no overlapping actors in my debugging program).
The point you made about the click-thru problem appearing even when destroying actors is interesting, i'll certainly look out for that. It's not a problem to put a time delay in as speed isn't a big issue in my app.
In my main program the click-thru issue is a big problem because each window that opens may contain many buttons which in turn may open other windows, so it's a certainty that at some point buttons will overlap (at different 'levels') so I have to get rid of the previous windows.
The program I've written for debugging is so small and so simple I just can't see why it doesn't work!
What's shown when I run prog : http://i1368.photobucket.com/albums/ag191/philm_0001/screen1_zps8ea7fbd8.jpg
When I press button the button is destroyed, the window (gray square) opens along with its close button, in the image the close button isn't on top of the window but that doesn't matter : http://i1368.photobucket.com/albums/ag191/philm_0001/screen2_zpsb600705a.jpg
When I press the [X] close button the window and close button are destroyed : http://i1368.photobucket.com/albums/ag191/philm_0001/screen3_zps3f5b44a6.jpg
The problem is that at this point I would expect the 'open window a' button to be spawned but it isnt. Here is the code:
controller code (note: the log statement 'run' does get called a second time as expected when the [x] is pressed but the button isn't spawned!) : http://i1368.photobucket.com/albums/ag191/philm_0001/controller_code_zps7c5d8177.jpg
button_open_window_a code : http://i1368.photobucket.com/albums/ag191/philm_0001/button_open_window_a_zpsc5b6948e.jpg
window_a code : http://i1368.photobucket.com/albums/ag191/philm_0001/window_a_zps495c8d60.jpg
close_window_a code:http://i1368.photobucket.com/albums/ag191/philm_0001/close_window_a_zps6273039c.jpg
But there are other ways to determine layering so that you can close only the top window of overlapping windows. Here is a demo:
http://forums.gamesalad.com/discussion/comment/436263/#Comment_436263