One user mentioned that in other game engines, GameObject is the root class but in The Render Engine it is HostObject. I decided to take his advice and create R.engine.GameObject, from which R.engine.HostObject is now derived (so instanceof checks should still work). HostObject is deprecated in favor of GameObject, so get used to it... ;-)
Also, I was thinking about why I've got this class called R.engine.Object2D... What makes it special? Why have it anyway? Well, I figured it out! Object2D now takes "transformComponent" as an argument to its constructor. If no value is provided, Object2D will get assigned an R.components.Transform2D by default. This way, set/get position, rotation, and scale all have a default implementation and will return actual values. You can still assign other transform components to a GameObject, but you'll always have at least one which can be accessed on Object2D via getDefaultTransformComponent(). Derivative classes now don't have to implement the setters and getters for position, rotation, and scale. Nothing says they can't override the methods, but they don't have to be implemented for a game object derived from Object2D to work. I've updated and tested this in the Asteroids Evolved demo and the Sprite demo I've been working on.
You can thank me later... =)
No comments:
Post a Comment