Problem with spawning

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

Comments

  • SocksSocks London, UK.Member Posts: 12,822
    Do you want a window that opens and closes when you click on it ?
  • bryanearlbryanearl Wasilla, AlaskaMember, PRO Posts: 49
    Only thing I could see is that you may need to move the "spawn button_open_window_a" on your controller BEFORE "set gss = 200" so the actor spawns before the attribute is changed.
  • bryanearlbryanearl Wasilla, AlaskaMember, PRO Posts: 49
    edited January 2014
    ... One more thought, I have had situations where the "clickthrough" happens even when destroying and spawning new actors in their place. It seems the new actor will spawn so fast that the "click/touch" still activates it if it is in the same position as the previous button. You could test to see if this is the problem by having your "open" and "close" buttons spawn in different locations so there is no chance of your "click/touch" hitting both buttons.

    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.
  • colandercolander Member Posts: 1,610
    I may be wrong but I think spawning is not the best way to handle buttons and should be avoided because it is more processor intensive and while they are on the screen they can still active even though you cant see them.

    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.
  • philmphilm Member Posts: 8
    Thanks for the replies.

    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



  • philmphilm Member Posts: 8
    Hi, does anyone have any ideas about this test program (above), still can't see what it the problem, any help would really be appreciated, cheers
  • RThurmanRThurman Member, Sous Chef, PRO Posts: 2,880
    @philm -- Sorry but its hard to read the windows version of GameSalad.

    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
  • philmphilm Member Posts: 8
    I've sorted this problem using variables. Thanks for all the replies :)
Sign In or Register to comment.