hi
i try to write a derived class of game.Layer , just like
Sprite or tiledLayer, so , i implement a paint() method.
but some problem appear:
code :
class testlayer extends Layer{
public paint(Graphics g){}
}
help me ,pls.
hi
i try to write a derived class of game.Layer , just like
Sprite or tiledLayer, so , i implement a paint() method.
but some problem appear:
code :
class testlayer extends Layer{
public paint(Graphics g){}
}
help me ,pls.
What’s the error message?
I’ve not written any J2ME, but I guess you’re missing a “void” in there:
class testlayer extends Layer{
public void paint(Graphics g){}
}
thanks to your reply
i think some problem occurs on constructor function,
but , i can’t find some documention about layer’s
constructor function in MIDP doc.
can u tell me how to get the layer's constructor function declaration?
thx
is there a noarg. constructor in the Layer class?
your error msg implies there isn’t.
i think there is no arg constructor method too.
But i can’t find layer’s constructor in MIDP api doc .
so , i discard this idea…
anyway, thanks to guys above .
Sadly, there is no way to write a derived class from Layer, which i have tried before.
I have downloaded the source file of MIDP from Sun, to see how to write the constructor of Sprite. From the constructor of Sprite, I found the constructor for Layer, which takes two parameters (int width, int height).
Then, i switched to the source code of Layer to see the details, the constructor there is declared as default, and there is a comment that declaring as default is to prevent developers from subclassing this class - Layer.
Since there is no way for me to declare my class to be in the same package as Layer, there is no way to sub-class Layer.
If anyone know any tricks to sub-class Layer, please tell me also!
Ya it’s messy that we can’t subclass Layer class.
In fact The only solution is to rewrite a more powerfull LayerManager that accept ExtraLayer and derived basic Layer.
Duuh
Mik