"last actor alive -> decrease score by 1 each second" not working

Exportforce

  • *
  • Posts: 90
Hello,

I am trying to fiddle around with a bit more user interaction and wanted to build a super simple game that creates bombs which the user has to click to "disarm" them. So I want to let the game create one bomb every 3 seconds. Per bomb per second the player score goes from 100 one down until it reaches zero, where the game shall end.
I tried the following codeblock on "create", "draw" and "update" but either get a freeze screen or the following error:

I tried to say "while last created actor is alive -> decrease score by 1 each second"

Codeblock: http://i.imgur.com/11Ce9Bv.png

Error:  game freeze
Can anyone point me a bit into the right direction?

« Last Edit: May 11, 2017, 06:50:05 am by Exportforce »

Luyren

  • *
  • Posts: 1751
From Stencylpedia:

While loop
"Runs the wrapped blocks while the given condition is true. If the condition is false to begin with, nothing will run. Make sure that the condition becomes false at some point during the evaluation of the loop (or use the exit loop block), otherwise it will result in an infinite loop that will crash your game."

Just place the point reduction in the bomb's behavior. You can use the trigger block to trigger an event for your scene behavior that manages points, for example.
Working.

Exportforce

  • *
  • Posts: 90
Yeah I thought that at some point too...
Still only ever worked with events, never used behaviours before.

edit: Got everything to work

« Last Edit: May 12, 2017, 12:45:11 am by Exportforce »