HKTMXTiledMap

This topic contains 297 replies, has 54 voices, and was last updated by  tanis 2 months, 2 weeks ago.

Viewing 25 posts - 1 through 25 (of 298 total)
Author Posts
Author Posts
June 24, 2011 at 1:47 am #232567

skyhawk
Participant
@skyhawk

So my friend and I have rewritten TMXTiledMap for our RPG out of necessity. We wanted maps that were large, Tiley, animated, and fast.

You use the class exactly the same as CCTMXTiledMap, however it only works for orthogonal maps. No iso or hex.

To animate tiles, you edit tile properties (via Tiled or whatever editor) to have “Next” which lists the next GID in the animation, and Delay (the delay between frames). It supports looped and one shot animations, but all animations have to be deterministic (no random)

It currently supports cocos2d 1.1 and cocos2d 2.1

It is under MIT license, so feel free to use in any project. Do let me know if you use it, I’m always excited to hear about people using my code. =)

From tests, it’s phenomenally faster for large maps, and moderately faster for maps just larger than screen size. Still slow in simulator, but on device performance is phenomenal.

Web page where you can always find the latest download and information: http://hkasoftware.com/index.php?object=HKTMXTiledMap

June 24, 2011 at 5:26 am #335005

Jim Love
@jim-love

Awesome! …except for me. :-( I’m building an iso game. How tough would it be to make it work for iso? Something a mediocre coder like me can do?

June 24, 2011 at 5:45 am #335006

actinism
Participant
@actinism

wow, nice stuff. thanks for sharing, will try it out. :-)

do you have any screen or video of your game in action?

June 24, 2011 at 5:57 am #335007

skyhawk
Participant
@skyhawk

Well since you asked nicely, here ya go. The game uses a 7 layer tiled map, with 5 layers visible. The other 2 are for collisions and triggers

http://hkasoftware.com/fileserve/SitS6.mov

in the sim… looks much smoother (framerate wise) on the iPad =)

Screenshot for those not wanting full movie

(placeholder townspeople ^^;;)

June 24, 2011 at 6:11 am #335008

actinism
Participant
@actinism

thank you! i was curious about to see that.

i like the placeholder ;-)

do you know the limitations of the maps, like 1000×1000 with a 32×32 pixel raster or something?

June 24, 2011 at 6:19 am #335009

skyhawk
Participant
@skyhawk

Tested it on a 525×555 map (just took the above and scattered junk all over the remaining area), and was still getting a solid framerate.

RAM usage was consistent with storing a map that large (which is to say completely reasonable)

Probably your biggest limitations with it will be:

1) many layers (potential to increase the number of sprites on screen)

2) RAM to store map, as well as any decent tilemap to cover such a large thing. If you use a small 1024×1024 tilemap to handle it, then it’ll likely not be an issue =)

Lastly, this has only been tested on Sim and on iPad 1 and iPad 2. I imagine it would work swimmingly on iPhone 3GS and iPhone 4, but it would need to be tested by someone who has those available

June 24, 2011 at 6:53 am #335010

actinism
Participant
@actinism

ok, thank you for that information. i think the layer issue could be managed if there are not so much “effect tiles”, i mean 5 layers + 2 object layers should work for most rpg games.

i guess i have to try something out now :-)

June 25, 2011 at 6:21 am #335011

psykano
@psykano

I just tested this on my iPhone 4. It did not work with my TMX files. My TMX files contain layers with different tiles but using the same image for the tile-set. I’m using the anchorPoint, visible and position properties of the HKTMXLayers within the HKTMXTiledMap.

The layers were displayed incorrectly and it crashed after running for a couple seconds.

June 25, 2011 at 7:01 am #335012

skyhawk
Participant
@skyhawk

would you mine sharing your TMX file + images so that I may test? or perhaps a callstack?

(just tested with tons of maps I just randomly generated in Tiled, all seem to work fine, so I would be eager to test yours).

June 25, 2011 at 8:05 pm #335013

skyhawk
Participant
@skyhawk

Huzzah, getting it working for Mac was easier than I thought. I’ll be posting that later.

Still working with psykano to figure out why his is crashing.

Really hoping more people will try this out and see if they get the results they are hoping for. It really is mind shattering the speedup for large maps.

June 26, 2011 at 10:02 pm #335014

skyhawk
Participant
@skyhawk

think I ironed out all the problems psykano had

June 27, 2011 at 1:12 am #335015

araker
Moderator
@araker

@skyhawk, nice work. I like the way you’re minimizing the data send to the GPU, efficient implementation.

This should be a cocos extension as well.

June 27, 2011 at 3:55 am #335016

skyhawk
Participant
@skyhawk

the mac version has a small bug when you resize the window, it has line artifacts on the borders of tiles (obviously doesn’t affect iOS)

-_-

June 27, 2011 at 6:49 am #335017

jandujar
@jandujar

I encorarage you to clone the cocos2d-extensions repository, add your TMX improvement, and share it with the comunity.

More people will apreciate your work. At least, me.

June 27, 2011 at 10:36 am #335018

tskarthik
Participant
@tskarthik

@skyhawk

Excellent stuff !!! This is awesome, exactly what I was looking for !! However, I did some tests and these are my observations:

1. Did not work properly on iPhone 4 (OS version 4.2.1), may be same problem as psykano had. As many people requested in the thread, I too encourage you to post this to extensions repository !!! It will really benefit the community.

2. I realized this code will not work on iOS versions earlier than 4.x+ due to usage of a dictionary function available only on iOS 4+ (enumerateKeysAndObjectsUsingBlock, I think). I have an iPad 1 with iOS version 3.x and the my app crashed. I had to get it working after commenting out the cyclic animation logic that uses this API. Considering that your game is targeted at iPad, do you intend to support only iOS 4+ ?

I am really impressed with how you have optimized drawing. Awesome stuff, and thanks a lot for sharing !!!

June 27, 2011 at 3:53 pm #335019

skyhawk
Participant
@skyhawk

1) part of Psykano’s problems were that he was trying it on 3.0.

2) All testing has been done on 4.3. Perhaps short sighted, but I see no reason to support < 4.0, as pretty soon 5.0 (and iPhone 5) is coming out. Which is indicative enough of how to progress. I realize this would get a lot of support for earlier gens though.

I’ll post to the git repo tonight. Unsure if I want to add the Mac code or not since it’s “buggy”

June 27, 2011 at 5:13 pm #335020

psykano
@psykano

Actually, I believe my problem is solely to do with it not working on a retina display device when retina display is enabled (enableRetinaDisplay:YES). I am not using animations and it works fine with my sd tile maps on my iPod Touch 1st gen. There is even a good speedup! I would very much appreciate if someone with an iPhone 4 with iOS 4.3 could test if it works when the retina display is enabled.

June 27, 2011 at 6:38 pm #335021

tskarthik
Participant
@tskarthik

@psykano

I forgot to mention in my previous post, I actually tested with retina display enabled (enableRetinaDisplay :YES) and I don’t use animations too; unfortunately couldn’t get it working.

June 27, 2011 at 7:07 pm #335022

skyhawk
Participant
@skyhawk

hmm, seems setting enableRetinaDisplay causes the problem (commenting that out seems to make it go away).

Will have to look more into that.

June 28, 2011 at 6:52 am #335023

skyhawk
Participant
@skyhawk

committed, and issued a pull

I’m sure I messed it all up =)

June 28, 2011 at 6:41 pm #335024

jandujar
@jandujar

waiting that psineur merge your changes. ;)

June 28, 2011 at 7:00 pm #335025

Stepan Generalov
Moderator
@ipsi

@skyhawk, almost not ;)

See the comment in pull request.

@jandujar

There’s something we need to improve/fix, before merging.

Feel free to help =)

June 29, 2011 at 7:36 am #335026

skyhawk
Participant
@skyhawk

fixed issues

June 29, 2011 at 11:37 am #335027

Stepan Generalov
Moderator
@ipsi

Cool, thanks! I will merge and try to fix retina crashes in few days.

First i will need to release 0.1.2

Crashing on retina is really big issue – who develops games for iOS now without retina support?

It should be fixed as soon as possible. Any heplers?

June 29, 2011 at 7:39 pm #335028

psykano
@psykano

I’ve been trying my best but I think it’s beyond my grasp.. on the other hand if anyone has a project or idea that might fix the bug, I’ll be happy to try it on my iPhone 4.

Viewing 25 posts - 1 through 25 (of 298 total)

You must be logged in to reply to this topic.