Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (711)
Games in Android Showcase (213)
games submitted by our members
Games in WIP (785)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  how to write a derived class from game.Layer?  (Read 2394 times)
0 Members and 1 Guest are viewing this topic.
Offline cyoui

Junior Newbie

Java games rock!

« Posted 2003-06-07 05:01:13 »

 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.
Offline cfmdobbie

Senior Devvie

Medals: 1

Who, me?

« Reply #1 - Posted 2003-06-07 09:05:25 »

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){}

Hellomynameis Charlie Dobbie.
Offline cyoui

Junior Newbie

Java games rock!

« Reply #2 - Posted 2003-06-08 10:38:51 »

thanks to your reply

no , i  did write a  paint() method like this:
class tlayer extends Layer{
public void paint(Graphics g){}
and the error message is
can't resolve symbol :
 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?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Ninja

Medals: 57

falling into the abyss of reality

« Reply #3 - Posted 2003-06-08 21:55:09 »

is there a noarg. constructor in the Layer class?

your error msg implies there isn't.
Offline cyoui

Junior Newbie

Java games rock!

« Reply #4 - Posted 2003-06-09 11:10:33 »

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 .
Offline hoshing

Junior Newbie

Java games rock!

« Reply #5 - Posted 2003-07-08 02:35:50 »

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!
Offline mik

Senior Newbie

Java games rock everywhere!

« Reply #6 - Posted 2003-07-08 05:51:19 »

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.


Pages: [1]
  ignore  |  Print  
You cannot reply to this message, because it is very, very old.

numerical (277 views)
2017-02-21 07:32:16

numerical (275 views)
2017-02-21 07:31:46

theagentd (387 views)
2017-02-18 13:42:33

theagentd (386 views)
2017-02-18 13:35:16

h.pernpeintner (1553 views)
2017-01-24 22:39:11

h.pernpeintner (1540 views)
2017-01-24 22:38:32

Galdo (2105 views)
2017-01-12 13:44:09

Archive (2105 views)
2017-01-02 05:31:41

0AndrewShepherd0 (2641 views)
2016-12-16 03:58:39

0AndrewShepherd0 (2348 views)
2016-12-15 21:50:57
List of Learning Resources
by elect
2016-09-09 09:47:55

List of Learning Resources
by elect
2016-09-08 09:47:20

List of Learning Resources
by elect
2016-09-08 09:46:51

List of Learning Resources
by elect
2016-09-08 09:46:27

List of Learning Resources
by elect
2016-09-08 09:45:41

List of Learning Resources
by elect
2016-09-08 08:39:20

List of Learning Resources
by elect
2016-09-08 08:38:19

Rendering resources
by Roquen
2016-08-08 05:55:21 is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!