Hey there XD
I've created a class that is 'son' of Sprite class.
The class simply does some src's and that so I don't need to do the process to all the pictures <.<
But, when using:
@variable = Bitmap.new(200, 200)
self.bitmap = @variable
Well, when im going to enter the game, it appears' Disposed sprite' <.<
Can someone help me? xD Blizzard helped me once with this but its giving me error on this class now lol
Where are you doing this? In initialize? In that case you should first call super.
Yes, with super it works <.< But I don't understand why I need super lol
When you call "super", the superclass' method with the same name is called. Before you call the initialize method of Sprite, it is considered non-existent (and disposed). If you try to assign a bitmap to a disposed Sprite instance, you get an error, that's why you first have to call the initialize method of Sprite through "super".
so, basically, am i calling initialize method from Sprite class? (by using super in this especiafically case)
Yes. You should always call super if you derive from a class and override an already existing method (such as initialize).
hmm...I see...imagine that a class have 2 arguments.
If I use super in a 'son' class, then it will be with the same 2 arguments right?
Yes. Though you can change the number of arguments in the method of the derived class, the superclass' method still needs to be called with the proper number of arguments through super. Just keep in mind that for 0 arguments you have to call explicitly "super()". Calling "super" calls the supermethod with the exact same arguments that you got in the current method.
BTW, it's called child class.
Well xD, in this case of Sprite, my super is 'super(nil)' xD
So, in the arguments, I just do as i do in a window... xD ok I think I finally get it now xD
thanks a lot, and for 'child class' information xD
I know this is fully resolved, but I read it and I am just impressed with Blizzard's knowledge and patience to explain in ways you can understand. If there was a facebook-like button, Blizzard, you'd be pretty popular in my book by now XD