level isometric

I am really new to Libgdx and game-programming ... That's my hobby

I have downloaded some images for a very easy city game. Its very simple to build a "one layer" map (Drawing Isometric game worlds) ,

Here it comes : an "eaxmple" for using a collection of images ! But as you can see on the image there is a background(blue) ... and then there are theese highrise buildings(red).So it's all multilevel and it fits perfect togehter ... So my question is : What is the best way to build something like this or are they any patterns for rendering? How can I display tiles in different height steps ?? For example a Bridge (eg like in TheoTown)??

an image example


Try sorting buildings by a z-index. In this case that would mean buildings closer to the bottom of the screen (regardless of their height) should be drawn last.

Here's an example of what I would do:

public class Building implements Comparable<Building> {
    //render, constructor, etc.
    public int compareTo(Building b) {
        return b.y - y;
        //sort buildings based on their distance from the bottom of the world
    }
}

In your rendering code, first sort the list of buildings, then draw:

Collections.sort(listOfBuildings);
for (Building b : listOfBuildings) {
    b.render();
}

I hope this helps! Btw, i can't test this right now, so it's possible that the drawing would be completely backwards, where the buildings at the top are drawn before the buildings below. If thats the case, play around with the compareTo method.

链接地址: http://www.djcxy.com/p/71212.html

上一篇: Java LibGDX:如何获取基于地图的坐标系?

下一篇: 水平等距