Note that there are some explanatory texts on larger screens.

plurals
  1. PORenderer/Sorting optimization
    primarykey
    data
    text
    <p>Okay here is the problem:</p> <ol> <li>i do have a list of Objects that does need to be updated by the time since the last frame</li> <li>the list need to be ordered by the y koordinate of the Object before they get draw</li> </ol> <p>Current i do this with a collection.sort and a simple comperator:</p> <pre><code>figureComperator = new Comparator&lt;Actor&gt;() { @Override public int compare(Actor o1, Actor o2) { return (int) o2.getY() - (int) o1.getY(); } }; </code></pre> <p>The render does look like this:</p> <pre><code>@Override public void render(float delta) { // clearing Gdx.gl.glClearColor(0, 0, 0, 1f); Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT); // act the character act in front this.character.myAct(delta); updateGameCam(); if (this.status == GameStatus.GAME) { // just monster act now this.figureStage.act(); } this.figureStage.getActors().sort(figureComperator); // sort figures // render background this.map.drawBackground(); // draw background // draw figures inclusive character this.figureStage.draw(); //draw all figures this.map.drawForeground(); // foreground // render game HUD and act gameHud this.gameHud.act(delta); this.gameHud.draw(); } </code></pre> <p>So i am looking for a better way to improve the speed of this.</p> <p>I do came across the idea of let the actors sort itself inside of the list(<code>figureStage</code>) while i do update those. But as i do the update forall with the <code>this.figureStage.act();</code> i couldnt do it that easy. </p> <p><strong>So my question is, if there is any solution without having the complexity of an sorting algorithm to always have those objects sorted by its position?</strong></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.
    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