You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In trying to subclass MG::Sprite I discovered that it is possible to subclass MG::Sprite. However, the technique is not intuitive. In order to subclass MG::Sprite you have to define a self.new method instead of the typical initialize method:
classCharacter < MG::Sprite# this works, but is not like Rubydefself.new(filename="default.png")puts"Executing Character.new"instance=superinstance.attach_physics_boxinstance.dynamic=falseinstance.scale=2instanceend# this is the approach that I would expect, but it does not get calleddefinitialize(filename="default.png")puts"Executing Character#initialize"# does not get calledsuperattach_physics_boxself.dynamic=falseself.scale=2endend
The text was updated successfully, but these errors were encountered:
In trying to subclass
MG::Sprite
I discovered that it is possible to subclassMG::Sprite
. However, the technique is not intuitive. In order to subclassMG::Sprite
you have to define aself.new
method instead of the typicalinitialize
method:The text was updated successfully, but these errors were encountered: