Problem with 'simple' code

BasGoodboyBasGoodboy Member, PRO Posts: 310
edited April 2014 in Working with GS (Mac)

Hey all,

I have a problem with a code which makes my Mac crash everytime and I don't get it why..

I have this island actor, which moves down and when it's out of sight it gets destroyed. Before the island actor gets destroyed, there is an ivisible actor in the middle of the screen, called 'spawning point'.

The island actor got the next rules:

-'when actor receives event > overlaps or collides > with actor 'spawning point':
change attribute > 'newisland' to random(1,3)

-When attribute > 'newisland' = 1
spawn actor island1 at position 80 > 450 relative to scene.

-When attribute > 'newisland' = 2
spawn actor island1 at position 80 > 450 relative to scene.

-When attribute > 'newisland' = 3
spawn actor devil at position 80 > 450 relative to scene.

Like this.. there is a chance of 2/3 a new island will appear, and a chance of 1/3 that a devil will appear.

Some way or another.. when I try this.. the game crashes at the 'spawning point', I don't get it.

Greetings,

Bas.

Goodboi Gamestudios | Monster Jumper now on the App Store

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949

    Is your initial island actor also called island1? If so, you're telling GameSalad to spawn another copy if it collides with the spawning point actor. That new copy will then immediately spawn another copy because it is colliding with the spawning point actor. The newest copy will then immediately spawn another copy... etc. causing a crash.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited April 2014

    Hey @tatiang. I understand what you mean but this is not the cause, since the spawning actor is halfway the screen it will not immediately spawn a new island1, but only halfway. I did this so there will be an endless spawning of new islands which will come row by row (not at the same time). This all works and I checked this.

    I first just had the island1 actor spawn another island1 actor as soon as it's colliding with the spawning actor, this was no problem. Since I have the random rule it crashes....

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598
    edited April 2014

    @BasGoodboy Hi Bas, the code's alright, 'cos that's written by the GS team... :wink:

    I'm not certain why your game crashes with your existing programming, but try this way to see if it cures it:

    Rule: When actor overlaps or collides with actor spawning point
    Change Attribute newisland to random(1,3)
    Rule -- nested in the above Rule, set to Any-- When attribute newisland = 1 or attribute newisland=2
    Spawn actor island1 at position 80 > 450 relative to scene
    Otherwise
    Spawn actor devil at position 80 > 450 relative to scene
    

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310

    @gyroscope super answer, now it doesn't crash anymore.. BUT

    Somehow, I have random (1,2), but it seems to spawn both 1 and 2 sometimes. I displayed the spawning attribute, and it seems alright, but still it has the devil and the island spawning at the same time when colliding with the spawning point at some points, how is this possible. I have setted random!

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • BasGoodboyBasGoodboy Member, PRO Posts: 310

    It works now, apparently something went wrong with double using an attribute. Thanks a lot @gyroscope

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • gyroscopegyroscope I am here.Member, Sous Chef, PRO Posts: 6,598

    You're welcome, Baz, glad it's sorted now. :smile:

    ""You are in a maze of twisty passages, all alike." - Zork        temp domain http://spidergriffin.wix.com/alphaghostapps

  • BasGoodboyBasGoodboy Member, PRO Posts: 310
    edited April 2014

    SOLVED.

    Goodboi Gamestudios | Monster Jumper now on the App Store

  • StormyStudioStormyStudio United KingdomMember Posts: 3,989
    edited April 2014

    is it cause the actor which overlaps or collides with spawning point, is triggering the same rule a few times...

    Could you add a rule that destroys the actor that triggers the spawning. Or have it bounce away from the spawning point.. or change a game attribute from 0 to 1 when it's spawned one and not allow it to spawn another until that game attribute has been reset to 0.

Sign In or Register to comment.