canceling an updating event ?

YobKgames

  • Posts: 63
for optimizing my game .
I wonder if we could cancel an when updating event and how? if not. Could I replace it with a do erey 0.01 second loop  and canceling it in a condition ??

« Last Edit: August 13, 2017, 08:00:46 pm by YobKgames »

Tuo

  • *
  • Posts: 2469
Hello,
A lot depends on how you want it cancelled. One simple way is to use a number attribute and check to see if it = a certain value. For example, if you wanted to cancel an updating event whenever there is a specific actor type/group on screen:

When updating
  set count = 0
  for each actor of type/group
       increment count by 1
  if count = 0
      DO CODE
Don't look to me but rather to the One who is the reason for what I do. :)

If you need help, send me a PM. Even if I haven't been on in the forums in ages, I still receive those messages via email notifications. You can also reply to any of my forum posts, regardless of the age (especially if I created it), and I will likely reply.

If you want to see the programming behind certain types of games, feel free to check out my "Demo-" games on StencylForge (http://community.stencyl.com/index.php/topic,16160.0.html)

JeffreyDriver

  • Posts: 2262
You could use a custom event with a boolean that triggers itself as long as the boolean is set to true.

designpeg

  • *
  • Posts: 731
JeffreyDriver's suggestion is my preference  - I've used this extensively. It also has the advantage that the event can fire immediatly, the repeat, rather that the ' do every x block' which waits until it fires for the first time.

merrak

  • *
  • Posts: 2738
...Could I replace it with a do erey 0.01 second loop  and canceling it in a condition ??

FYI: An 'always' event fires on every engine step, which is .01 second.

letmethink

  • *
  • Posts: 2545
...Could I replace it with a do erey 0.01 second loop  and canceling it in a condition ??

FYI: An 'always' event fires on every engine step, which is .01 second.
Isn't that exactly what he said? He wants to use a loop so he can cancel it but still wants it to act as an updating event.
~Letmethink

Bhoopalan

  • Posts: 1018
I have also done what Jeffrey says quite often to achieve what you are looking for.

...Could I replace it with a do erey 0.01 second loop  and canceling it in a condition ??

FYI: An 'always' event fires on every engine step, which is .01 second.
Isn't that exactly what he said? He wants to use a loop so he can cancel it but still wants it to act as an updating event.

I have the same question. I even had to read it twice whether I overlooked something :)
If I helped you at anytime, help me back build my twitter followers :)
https://twitter.com/imbhoopalan

merrak

  • *
  • Posts: 2738
I think I misread the original post :P