This site requires JavaScript, please enable it in your browser!
Greenfoot back
Excelsior
Excelsior wrote ...

2014/3/18

Drawing an image on whole world

Excelsior Excelsior

2014/3/18

#
Hello, I would like to ask if it is possible to draw an image (like shadowmap) on the whole screen after the objects have been placed?
Excelsior Excelsior

2014/3/18

#
Well, atleast if anyone else is interested, you can do it by making an actor and placing it in the center of the world. You will only have to make sure it doesn't interrupt with collision system and is drawn PRIOR to everything else. Altough, I'm open to any kind of suggestion if there is a better way to do it.
danpost danpost

2014/3/18

#
You could save the current background image of the world in a field (as a new GreenfootImage) and then draw your image onto the background. Then to remove, just set the saved image as the background image of the world. The following is like for within an Actor subclass:
1
2
3
4
5
6
private GreenfootImage heldBG; // field to hold the background image
// with 'GreenfootImage shadowmap' as your image, adding it
heldBG = new GreenfootImage(getWorld().getBackground());
getWorld().getBackground().drawImage(shadowmap, 0, 0);
// removing it
getWorld().setBackground(heldBG);
Hope this helps.
Excelsior Excelsior

2014/3/19

#
Well, as far as I've tried it, I've only got greenfoot to paint it on the background BELOW all the actors, so only the background gets the shading. Making the shadowmap an object and setting it a top draw priority does the effect just fine.
danpost danpost

2014/3/19

#
Excelsior wrote...
Well, atleast if anyone else is interested, you can do it by making an actor and placing it in the center of the world. You will only have to make sure it doesn't interrupt with collision system and is drawn PRIOR to everything else.
I believe I was mislead by 'drawn PRIOR to everything else', which would place it under the other objects, not over. As an actor overtop of everything, the only thing that will be affected is what actor mouse actions occur on.
Excelsior Excelsior

2014/3/19

#
Sorry, my mistake.
You need to login to post a reply.