Cocos2d-x, TileMap and Android issue

Hi,

I try to use Cocos2d-X with TileMap for Android/iOS development with this tutorial (http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d).

If I run this example in iOS emulator (iPad) all work correctly http://dl.dropbox.com/u/29577337/iOS.png ,but if I run on Android (Galaxy S 2 or Galaxy Tab 10.1 ) I see some artifacts:

http://dl.dropbox.com/u/29577337/android_phone.png - Galaxy S 2, Android 4.0.4
http://dl.dropbox.com/u/29577337/android_tablet.png - Galaxy Tab 10.1 Android 4.1.2, Tegra2

I think, this is due to loss of precision in Android version Cocos2D-x.

Hi, well I had the same problem, for android need change this file CCTMXXMLParser.cpp in line 456 you will find:

tileset~~>m_sSourceImage = m_sResources + “/” + imagename;
Change for this:
if
{
tileset~~>m_sSourceImage = m_sResources + “/” + imagename;
}
else
{
tileset->m_sSourceImage = imagename;
}

The problem is by the slash (/)

Try and response if you have some other problem.

Good luck.

Hi,

thank you for help!

I use Cocos2D-x 2.0.3 and in my case this line is

tileset->m_sSourceImage = m_sResources + (m_sResources.size() ? "/" : "") + imagename;

If I change this code to

@
if( m_sResources!=“” ) {
tileset~~>m_sSourceImage = m_sResources + “/” + imagename;
}
else {
tileset~~>m_sSourceImage = imagename;
}
@

it has no effect for me.

Oh well really I’m not sure in my case the TMX in android works fine. Could you reload the pictures? I try to help you if I can =D

Hi, today I tested this app on real iPad 2 and I got some results. :slight_smile: This not only android issue.

New pictures:

http://dl.dropbox.com/u/29577337/android_phone.png Galaxy S II (Android 4.0.4)
http://dl.dropbox.com/u/29577337/android_tablet.png Galaxy Tab 10.1 (Android 4.1.2)
http://dl.dropbox.com/u/29577337/iOS_iPad.png - iPad 3 (iOS 5.1.1)

http://dl.dropbox.com/u/29577337/iOS.png - iPad Emulator (iOS 6.0) It has no issue.

Ahhhhh yes I remember that to fix find the file ccConfig.h in directory cocos2dx/include/ccConfig.h find this line:

CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL

And add 1 to the end:

CC_FIX_ARTIFACTS_BY_STRECHING_TEXEL 1

Here http://www.cocos2d-x.org/boards/6/topics/8401 talk about this solutions.

Thank you! It works!

Great man =D if you have other problem I will pleasure to help you.