Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

TreizeSG

[java] Transparent canvas, background images?

This topic is 5513 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In order to avoid flashing while drawing, I came up with an idea, but I don''t know if it is possible to do in Java... With any sort of Java API, could I place one canvas on the "bottom," underneath anything, not changing until it is told to change. On top of that, would go a transparent canvas, except for the areas where the characters are drawn. Is this possible?

Share this post


Link to post
Share on other sites
Advertisement
First, don''t use Canvas, use Panel.

Second, to avoid flashing, you use a backbuffer. Create a blank Image, do all your drawing to that Image, then draw that Image to the Panel. You also have to overridge the update() method like this:

public void update(Graphics g) {
paint(g);
}




First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites
OMG, that worked REALLY well. The course I took as an "Intro to Java" had a phrase that went:


Override paint, call repaint, and don''t mess with update.


Guess there are some situations where abovePhrase == false;

Share this post


Link to post
Share on other sites
What they mean is don''t call update directly. You always call repaint.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!