what`s wrong with my loop?

tpiardi

  • Posts: 7
super is a simple boolean, but my game  crashes every time the while function is triggered.





it's a pac man like game, the bollean starts in FALSE, and change to TRUE in the moment the main character get's the  power up.

« Last Edit: April 07, 2015, 10:53:08 am by tpiardi »

Creis

  • Posts: 102
What makes "Super" true or false? Can you put a screenshot of the whole behaviour (camera icon on the lower right)?

SadiQ

  • Posts: 1791
The loop fails because you used a while loop inside an Always event. Try replacing a while loop with an If block and adjust your code.
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

tpiardi

  • Posts: 7
Crels, I updated with the requests, thank you.

Will also try to use if,  but it will not make my verification run only one time:

SadiQ

  • Posts: 1791
Try something like:
If Super = true
    Push self at -5 force
otherwise
    Push self at 5 force
Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Photon

  • Posts: 2697
A while loop will monopolize control until its condition is fulfilled (or it is explicitly "canceled".) If "super" is not set to false INSIDE the loop, you've potentially got an infinite loop.
Do NOT PM me your questions, because I likely will not respond. If I have replied to your question on the forum, keep using that topic. Thanks!