Note that there are some explanatory texts on larger screens.

plurals
  1. PO2D Java Game. Moving sprite above tiled images
    primarykey
    data
    text
    <h2>-><strong><em>Short Introduction, you can SKIP this part</em></strong><br></h2> <p><em>I'm glad to be able to finally post on this platform, because I for myself have gained so much knowledge through this community; just by reading. So I wanted to say "Hello everybody, and thank you!</em></p> <h2>Actual Content(prologue):</h2> <p>Though I'm developing in Objective-C in my company, I am utterly interested in JAVA development. I am quite comfortable with the syntax but have some major troubles with awt/swing/Graphics2D.</p> <h2>The Concept:</h2> <p>JAVA Application with a 800*600 Frame. On this Frame you can see 16*12 tiles (i.e. gras.jpg or tree.jpg) with a size of 50px². Above this Frame a .png "player" is moving. The field is generated with a 2 dimensional int array[16][12] where a 0 symbolizes "gras" and 1 means "tree".</p> <p>-> This is actually "working".</p> <h2>First Try:</h2> <p>Adding (frame.add(...)) 16*12 JLabels with imageIcon "gras" or "tree" to a JLayeredPane<br> Adding (frame.add(...)) class "entityLayer" wich is updated at 5ms with paint(Graphics g)<br>{<br>g.drawImage(imageIcon.getImage());<br>}<br>This Version "works" if I add <em>either</em> the field with tiles <em>or</em> the entity layer. In every case else either the entityLayer overlays the field with a grey background or the "player" is not visible under the field;</p> <h2>Second Try:</h2> <p>Making all the drawings in the entityLayer paint(Graphics g) method. But thats not what I intended. I want the field to be drawn once and the "player" with, like a translucent background, drawn <em>above</em> the field.</p> <h2>Question:</h2> <p>How can I get myself in a position to actually have two seperate layers, that are both equally independent with out having one overlapping the other? Im nearly 99% shure my attempt is wrong in some way.</p> <p>Thank you right away.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload