Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (538)
Games in Android Showcase (132)
games submitted by our members
Games in WIP (600)
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  
  Extending Layer: bug?  (Read 1107 times)
0 Members and 1 Guest are viewing this topic.
Offline danielmfreitas

Senior Newbie




Java games rock!


« Posted 2005-03-07 14:35:45 »

I just found out that even with the API Javadocs leading you to believe it is possible to subclass layer by saying "Layer subclasses must implement a paint(Graphics) method so that they can be rendered", the class cannot be subclassed by MIDP 2 developers.

The constructor of class Layer has default visibility, meaning that only classes within the same package can see the constructor.

I really believe it's a bug. I see no reason for it to be this way. If they wanted the developers not to be able to extend Layer functionality, they would also make Sprite and TiledLayer final classes.  As of today, the only way to extend a Layer is by subclassing one of those, wich is very ackward if what you intend is to create a diferent kind of a layer.

What are your soughts about that? I have found nothing on Sun about it.
Offline davidaprice

Junior Devvie





« Reply #1 - Posted 2005-03-08 05:58:01 »

I think it's deliberate that Layer can't be subclassed: the idea is that you should subclass Sprite or TiledLayer. This allows the API's implementation to assume that all Layers are either Sprites or TiledLayers, which might simplify the implementation.

I agree, it should be made clearer. I remember being puzzled about this when I first noticed it.
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #2 - Posted 2005-03-08 18:13:07 »

While we're on the subject - do you know of a zip/jar or other type of archive that I can download to view the source of the J2ME MIDP2.0 classes.  I've got the API, but I'd like to look a little deeper as to what exactly is happening when I call certain methods.  

Also, on the subject of subclassing can someone confirm that it is also not possible to create a subclass of Image?

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Abuse

JGO Knight


Medals: 14


falling into the abyss of reality


« Reply #3 - Posted 2005-03-08 20:31:34 »

Quote
While we're on the subject - do you know of a zip/jar or other type of archive that I can download to view the source of the J2ME MIDP2.0 classes. I've got the API, but I'd like to look a little deeper as to what exactly is happening when I call certain methods.


Just reverse compile the libs.

Quote
Also, on the subject of subclassing can someone confirm that it is also not possible to create a subclass of Image?


The Image class has no constructor, only factory methods - it is therefor impossible to subclass it.

Make Elite IV:Dangerous happen! Pledge your backing at KICKSTARTER here! https://dl.dropbox.com/u/54785909/EliteIVsmaller.png
Offline davidaprice

Junior Devvie





« Reply #4 - Posted 2005-03-09 08:15:58 »

Quote
While we're on the subject - do you know of a zip/jar or other type of archive that I can download to view the source of the J2ME MIDP2.0 classes.  I've got the API, but I'd like to look a little deeper as to what exactly is happening when I call certain methods.


The API is the only thing that's standard - the implementation will vary between phones. Even if you got hold of the source for Sun's reference implementation or some manufacturer's own implementation, you couldn't rely on what you learn being true for other implementations.
Offline ribot

Junior Devvie




Ribot - mobile UI specialist


« Reply #5 - Posted 2005-03-09 08:19:37 »

I was just hoping that I could learn some commonly used methods of optimisation by looking at the API reference source code.

http://ribot.co.uk - design agency focused on mobile
http://www.retrospecs.co.uk - online vintage eyewear store
Offline danielmfreitas

Senior Newbie




Java games rock!


« Reply #6 - Posted 2005-03-09 14:35:07 »

I think the code from the reference implementation is not optimized at all. For instance, TiledLayer is painfully slow. Its faster to draw the scene with clipping and drawImage().

The Nokia implementation, though, is quite fast. On the game I'm working on, a screen composed of 15x12 tiles, each tile 16x16 pixels, runs at 21 FPS on Sun's implementation. On Nokia emulator it jumps to 62 FPS. Almost 3 times faster.

Other emulators (Sony Ericsson for instance) is just a diferent face for the sun wtk. They use the same, slow, code. I'm eager to test my app on a real device to see how it performs.
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

rwatson462 (29 views)
2014-12-15 09:26:44

Mr.CodeIt (20 views)
2014-12-14 19:50:38

BurntPizza (40 views)
2014-12-09 22:41:13

BurntPizza (75 views)
2014-12-08 04:46:31

JscottyBieshaar (37 views)
2014-12-05 12:39:02

SHC (50 views)
2014-12-03 16:27:13

CopyableCougar4 (45 views)
2014-11-29 21:32:03

toopeicgaming1999 (113 views)
2014-11-26 15:22:04

toopeicgaming1999 (100 views)
2014-11-26 15:20:36

toopeicgaming1999 (30 views)
2014-11-26 15:20:08
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org 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‑gaming.org
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!