My questioin is pretty much in the title, Why do I keep reading in actionscript 3.0 that its a good idea to seperate the 'mind' from the 'object' when writing code?
Thanks for any help, this is confusing the hell out of me.
My questioin is pretty much in the title, Why do I keep reading in actionscript 3.0 that its a good idea to seperate the 'mind' from the 'object' when writing code?
Thanks for any help, this is confusing the hell out of me.
If you're asking why graphics are separated from the positioning, movement and physics; take this tree I've drawn:
In the tree you'll see that
Entity
has two properties:Moving down, you will see that there are several things that extend
Entity
- most notable are thePlayer
and theEnemy
classes.Extending my
Entity
class above, I can easily change what should be used as thegraphics
and also provide slightly differentbodies
. For example, the player and enemies will have obviously different appearances, and theTree
class won't need to use aBody
that deals with values like velocity because it doesn't move.Here are some advantages of the above:
MovieClip
if you had extendedMovieClip
with yourEntity
class.Graphics
class such as being able to easily covert a Sprite or MovieClip into a sprite sheet for better performance.Body
can be updated without immediate effects on the graphics.