Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8953737
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:09:55+00:00 2026-06-15T14:09:55+00:00

I want to make isometric, tile-based, iPhone games with cocos2D. Sprites need to be

  • 0

I want to make isometric, tile-based, iPhone games with cocos2D.

Sprites need to be drawn on-top of other sprites that are “behind” it. I’m looking for the best way to do this.

I’d like to avoid the painter’s algorithm because it involves sorting all the sprites every frame which is expensive.

The Z buffer algorithm is supported by the GPU and cocos2D so this is what I’d like to use, but there is a problem. Some sprites, like buildings for example, occupy multiple tiles. Assigning a Z value to such sprites is difficult.

These are the options I’ve thought of:

  1. Comparing two buildings and determining which one is “in-front” is
    easy. So buildings can be sorted then assigned a Z value based on
    the sort order. This wouldn’t be any different from the painter’s
    algorithm. The OpenGl ES Z buffer wouldn’t be necessary.
  2. Assign a Z value to each building based purely on its location on
    the map (without knowledge of where other buildings are). I’m
    finding this difficult. I think it is possible, but I haven’t been
    able to come up with a formula yet.
  3. Use multiple sprites for images that occupy more than one tile, so
    all sprites will be exactly the same size. Z orders can then be
    easily assigned based on what tile the sprite is occupying. The
    problem with this solution is that it makes the game logic much more
    complicated. All operations on a single building will have to be
    repeated for each sprite the building is made-up of. I’d like to
    treat each object as a single entity.
  4. Modify the cocos2D code to allow sprites to have multiple Z values
    at different points. If a sprite can have multiple Z values based on
    what tile a particular part of the sprite falls on, then calculating
    a Z value for that section is easy. I won’t need to compare the
    sprite to any other sprites. I believe this is possible by using
    multiple quads for each sprite. The problem with this is that it is
    a bit complicated for me since I am new to OpenGL ES and cocos2D. I
    don’t completely understand how all of the internal data structures
    work. Although it seems like the most elegant solution if a formula
    cannot be found.

I will up-vote any suggestions or references to helpful resources.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T14:09:56+00:00Added an answer on June 15, 2026 at 2:09 pm

    For #2, you can compute the Manhattan distance of the center of the object and use this value as the z-value of that object. It will work as long as you avoid very long objects in your map like 5×1 object or worse. But if you really need a long object to be placed in a tiled map, managing the z-order of objects in the map by setting a z-value using a formula is impossible.

    To prove this:
    1.) Place two 2×2 objects in a map horizontally and leave a unit tile between them.
    2.) Place a 3×1 object between them. Let’s name the 2×2 objects to A and B, and the 3×1 object to C.
    3.) If you just rotate C(not changing its position), z-order of A and B interchange.

    -If B is now in front, some objects behind B will be in front of A because of just the rotation of C. And it’s costly to know which objects in back of both A and B previously will become in front of A after C’s rotation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Are cocos2d-iphone and cocos2d-Android the same thing? in other words, can I make a
I want make an iphone app that has a UITableView that displays different texts
I want make a xslt transformation to xsl-fo but I´m not really sure that
I want make the control height as double when the mouse is over that
i want make function like that function(data){ } i want this data as this
I want make a page (HTML + CSS) that fits all the space left
I want make a UI that is semi transparent in WPF VS2008, so I
I make Iphone application and I want make my table view to look like
i want make a news site gets its content from other news sites, open
I want make digital sign in iphone...is it possible in iphone via xcode...

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.