Whats the reason for 'Always' to not execute draw commands?

Ganu

  • Posts: 224
Hi, I was wondering why we cant place draw block in always wrapper, but we can do everything in drawing wrapper... Does 'Always' and 'When drawing' have some diferences?
Currently waiting for joints in stencylworks.

captaincomic

  • *
  • Posts: 6108
The "when drawing" event has a reference to the Graphics object g, which is needed for the drawing blocks. You can see it if you look at the code preview.

Ganu

  • Posts: 224
Ok. But why not merge "always and draw" wrappers then?
Currently waiting for joints in stencylworks.

ipe 369

  • Posts: 1001
Because they are two separate functions. You can't instantiate a graphics object the normal way, using new Graphics() Or whatever, it must be passed down to you through a function (The draw function, which is the draw wrapper) Or you must extend a class with a Graphics object as one of its members. Actionscript will either call draw or always, but you can't set what will trigger the event.
I'm not quite sure if i'm right tbf. It may be because it's difficult to alter the engine like that, and it's also better this way to keep things separate. But meh.

Ryusui

  • Posts: 827
Because decoupling the drawing functionality from the game logic is a good idea.

If the machine is too slow to run at a consistent framerate, this way the game still runs at the same speed with frameskip instead of slowdown - or nasty glitches.
In the event of a firestorm, the salad bar will remain open.

Alexin

  • *
  • Posts: 3130
Design Mode users don't have to know about Graphics objects or any other internals.
The most relevant answer is Ryusui's.
"Find the fun"
alexin@stencyl.com

Ganu

  • Posts: 224
Thanks, I didnt know there are graphical objects. :D
Currently waiting for joints in stencylworks.