Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Game Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-25-2011, 06:24 AM   #1 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default Cocos2d and Tiled

Hey guys, i have started having a look into cocos 2d this morning, my plan is to use it to create a game over the next year, so getting the basics laid out now.

I have been following a few of Ray Wenderlich's tutorials, and have come across this one:
How To Make a Tile Based Game with Cocos2D | Ray Wenderlich

Now i can get through the tutorial OK if i use the .tmx that he supplies with his code, but using my own code. However if i used Tiled to create my own "map" to use then i cant get past the launch image. The error i am getting is this:
Quote:
cocos2d: CCTexture2D. Can't create Texture. UIImage is nil
2011-05-25 12:07:48.441 TileTestTwo[7513:207] cocos2d: Couldn't add image:../Work/Games tests/TileGame/TileGame/tmw_desert_spacing.png in CCTextureCache
The only thing i can think of being a problem is the space in the above url (Game tests) but i dont see why that should cause a problem. I have checked all file names, locations and they all check out to be correct. I have tried a clean and rebuild, i have created a new project, and a new map in Tiled and attempted that. still nothing. The only way that i can get it to work is by using the supplied .tmx "map" rather than my own.

I dont want to move ahead of this tutorial if i cant even get this working, but i cant see why it wouldnt be working.

I think (i can only tell by dates of posts) that there will be difference in the Xcode version i am using (i am on 4) i guess as it was june 2010 that tutorial was release that it was done in Xcode 3. Also there seems to have been an update to cocos, i am using 1.0.0, again i would assume by date that Ray was using ~0.9. And now Tiled doesnt offer a java version (not that i could see) i guess there have been a fair few updates to that since Ray made the tutorial.

Could anyone help out here? i would be happy to email my test project as a zip if anyone feels it could help clear this up - its only a project to display a background map.

Sorry if this is a bit noobish, but im back to the drawing-board with this now.
Thanks in advance Joe
Meredi86 is offline   Reply With Quote
Old 05-25-2011, 09:54 AM   #2 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

the image in on .app generated? are you sure that the image is not corrupted? try another image...
__________________
dany_dev is offline   Reply With Quote
Old 05-25-2011, 10:02 AM   #3 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default

1. if i right click, show package contents on the .app i can see the image there: TileMap.tmx, as is: tmw_desert_spacing.png. So that should be ok from that point of view.

2. I am certain that the image isnt corrupted. I can open: tmw_desert_spacing.png in preview and there is nothing out of place, and i have saved two different .tmx's and tried both of them - with the same results.

3. I have tried the images from the tutorials source folder, and they work fine. though i only have to change the .tmx to make it work, which is why i assume that that has the problem.

In case this makes any difference. This is the xml from the tutorials .tmx:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="50" height="50" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="tmw_desert_spacing" tilewidth="32" tileheight="32" spacing="1" margin="1">
  <image source="tmw_desert_spacing.png"/>
 </tileset>
 <layer name="Background" width="50" height="50">
  <data encoding="base64" compression="gzip">
   H4sIAAAAAAAAA+3YIQ6AMAwF0AEKEATwSO5/RCoRmGHY2BMvaVLzRb/pkVI6gOZ0oQ9DAVlynbd5DFOYH3Y1WcMW9gKytGbJ8HXWFtXaaQAAAAAA/s8Pm1xuBvLpDW9ciGmfRhAnAAA=
  </data>
 </layer>
 <objectgroup name="Objects" width="50" height="50">
  <object name="SpawnPoint" x="51" y="301"/>
 </objectgroup>
</map>
And this is the xml from MY .tmx:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="50" height="50" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="tmw_desert_spacing" tilewidth="32" tileheight="32" spacing="1" margin="1">
  <image source="../Work/Games tests/TileGame/TileGame/tmw_desert_spacing.png" width="265" height="199"/>
 </tileset>
 <layer name="Background" width="50" height="50">
  <data encoding="base64" compression="zlib">
   eJztz6ENACAMALAFHDjw/H8mJzA5kooe0BMRBwD4WiuuJx+juOlRSvaxitvJBwAAAAAAAPB2Acs9FQk=
  </data>
 </layer>
</map>
as you can see there are one or two differences here, such as the compression. I dont know if that could change anything though, and if it does i am unaware as to how to solve such a problem. there seems to be no other save or compression options i can see in tiles.

Edit
Scratch that last sentence - i just found in preferences how to change the compression to the one the tutorial uses - off to test with fingers crossed!!

Edit two Nope with that changed and this as the new xml:
Code:
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="50" height="50" tilewidth="32" tileheight="32">
 <tileset firstgid="1" name="tmw_desert_spacing" tilewidth="32" tileheight="32" spacing="1" margin="1">
  <image source="../Work/Games tests/TileGame/TileGame/tmw_desert_spacing.png" width="265" height="199"/>
 </tileset>
 <layer name="Background" width="50" height="50">
  <data encoding="base64" compression="gzip">
   H4sIAAAAAAAAA+3PoQ0AIAwAsAUcOPD8fyYnMDmSih7QExEHAPhaK64nH6O46VFK9rGK28kHAAAAAAAA8HYB8xytphAnAAA=
  </data>
 </layer>
</map>
I still get the same error.

Last edited by Meredi86; 05-25-2011 at 10:07 AM. Reason: Adding in edit and edit 2
Meredi86 is offline   Reply With Quote
Old 05-25-2011, 10:11 AM   #4 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default

got it. If you look at my xml there is a huge file path:
Code:
../Work/Games tests/TileGame/TileGame/tmw_desert_spacing.png
What i did was turn that into this:
Code:
tmw_desert_spacing.png
And hey presto it worked. I love figuring these things out

Next though is why did it save it with that url? and is there a way i can prevent it in the future?
Meredi86 is offline   Reply With Quote
Old 05-25-2011, 10:46 AM   #5 (permalink)
Nuisance Developer
 
Join Date: Jul 2009
Location: Italy
Posts: 4,691
dany_dev is on a distinguished road
Default

because the editor generated it assuming a relative path....probably if you create it selecting the image that are already on the same directory of the tmx, will not add anyother that file name.....
__________________
dany_dev is offline   Reply With Quote
Old 05-25-2011, 10:50 AM   #6 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 1,106
Meredi86 is on a distinguished road
Default

ok so it was just the brows location that was messing me around. Cool that i believe is in my ability to fix and prevent

Thanks dany, i can move on to bigger and better things now
Meredi86 is offline   Reply With Quote
Old 08-08-2011, 09:47 AM   #7 (permalink)
Mishti
 
Join Date: Mar 2011
Location: Mumbai
Posts: 28
mishti is on a distinguished road
Default

Quote:
Originally Posted by Meredi86 View Post
ok so it was just the brows location that was messing me around. Cool that i believe is in my ability to fix and prevent

Thanks dany, i can move on to bigger and better things now
Hiii
I m new be in cocos2d . i used "http://www.raywenderlich.com/1163/how-to-make-a-tile-based-game-with-cocos2d" this tutorial . According to this code , i created my code , but this code gives the error:

2011-08-08 20:03:57.499 TileDemo[6971:207] *** Assertion failure in -[CCTMXMapInfo parser:didStartElement:namespaceURI:qualifiedName: attributes:], /Users/computerdepot/TileDemo/libs/cocos2d/CCTMXXMLParser.m:300
2011-08-08 20:03:57.503 TileDemo[6971:207] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'TMX: unsupported compression method'
*** Call stack at first throw:
I didn't understood this error.

My xml file:

<?xml version="1.0" encoding="UTF-8"?>
<map version="1.0" orientation="orthogonal" width="15" height="10" tilewidth="32" tileheight="32">
<tileset firstgid="1" name="Final" tilewidth="32" tileheight="32" spacing="0" margin="0">
<image source="Final.png" width="480" height="320"/>
</tileset>
<layer name="Background" width="15" height="10">
<data encoding="base64" compression="zlib">
eJxjZGBgYIRiFiQ2MXyBAcJ6QxBHD0HcSQEGAL3wIhU=
</data>
</layer>
<objectgroup name="objects" width="15" height="10">
<object name="obj" x="226" y="305">
</object>
</objectgroup>
</map>


Plz give response as soon as possible.
Thank u vry much
mishti is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 426
7 members and 419 guests
AppleDev, chemistry, Emy, hussain1982, mistergreen2011, Retouchable, skrew88
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,679
Threads: 94,128
Posts: 402,922
Top Poster: BrianSlick (7,990)
Welcome to our newest member, xzoonxoom
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 08:17 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0