Canvas GoDView = new EngineCanvas();
vs.
EngineCanvas GoDView = new EngineCanvas();
----
There is no "right way" for this - it depends on what you need. If you want to transparently use an EngineCanvas in place of Canvas then the first way will do just fine. The second way is useful if you know you need to talk to an instance of EngineCanvas - so you can call Engine Canvas specific methods that aren''t found on Canvas.
[java] Embarrassing question about my own code...
Moving the painting to repaint() doesn''t change anything as the repaint() actually invokes paint() after clearing the background...
Just change the line reading:
g.drawImage( Background, 0, 0, this );
to
g.drawImage( Background, 0, 0, null );
in the example and it works. At least in the example you don''t need the ImageObserver. Also in your original code you don''t seem to need it if you are handling the loading in different place anyhow and make sure the images are loaded before you draw them.
I was just commenting that loading an image in paint() sounds like a bit odd idea as image loading can take quite a long time. Doing the image loading in some init() method would be more appropriate, but that was not the point of the example anyhow...
Maploader? Now I''m getting confused... imageController sounds like a controller of all used images, but what on earth does a maploader do in this mess? Well, anyhow you asked why your example code doesn''t work and after that change it''ll work, so that should answer your original question, right?
Just change the line reading:
g.drawImage( Background, 0, 0, this );
to
g.drawImage( Background, 0, 0, null );
in the example and it works. At least in the example you don''t need the ImageObserver. Also in your original code you don''t seem to need it if you are handling the loading in different place anyhow and make sure the images are loaded before you draw them.
I was just commenting that loading an image in paint() sounds like a bit odd idea as image loading can take quite a long time. Doing the image loading in some init() method would be more appropriate, but that was not the point of the example anyhow...
Maploader? Now I''m getting confused... imageController sounds like a controller of all used images, but what on earth does a maploader do in this mess? Well, anyhow you asked why your example code doesn''t work and after that change it''ll work, so that should answer your original question, right?
-Pasi Keranen
Maploader is actually named wrong, it should be mapCreator, because I''ll create dynamic maps except world and town maps, I once did this with C++ and with that experience I think I''ll do it in different object...
Something is perfectly messed... while I can draw retangles and ovals I can''t draw image anyhow... None of these examples didn''t work, I quess there is little object structure fault which causes that I can''t draw images on a canvas... Weird huh? That null thing didn''t work I quess I''m now out of ways to do this in this way...
Hey don''t call my thingie mess, It''s not mess, it''s just... complicated...
Hey don''t call my thingie mess, It''s not mess, it''s just... complicated...
Messy, complicated, whatever... Either way in real workplace you would be put to write it again
But hey, this is the reason I''m writing things on my spare time, nobody is watching over the shoulder
One thing came to my mind. Are you sure that a window peer has been created when you load the images? In other words, a window has been shown and it has received addNotify() notification? Or was this only needed for that createImage(int, int) method?
But hey, this is the reason I''m writing things on my spare time, nobody is watching over the shoulder
One thing came to my mind. Are you sure that a window peer has been created when you load the images? In other words, a window has been shown and it has received addNotify() notification? Or was this only needed for that createImage(int, int) method?
-Pasi Keranen
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement