How To Make a Tile-Based Game with Cocos2D 2.X

Discussion of the official tutorials published on raywenderlich.com. Please only discuss the official tutorials here - for general questions, use the General Discussion forum instead.

How To Make a Tile-Based Game with Cocos2D 2.X

Postby rwenderlich » Fri Feb 08, 2013 11:00 am

This is the official thread to discuss the following blog post: How To Make a Tile-Based Game with Cocos2D 2.X
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
Ray Wenderlich
Blog: http://www.raywenderlich.com
Twitter: http://twitter.com/rwenderlich
- - - - - - - - - - - - - - - - - - - - - - - - - - - -
User avatar
rwenderlich
Team Member
Site Admin
 
Posts: 2155
Joined: Thu Dec 23, 2010 4:14 pm
Has thanked: 28 times
Been thanked: 337 times

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby romox » Sat Feb 23, 2013 5:17 am

hello, i didn't understand the "setViewPointCenter" part, the diagram isn't clear enough, could you make the diagram more clear please? thanks a lot! :D
romox
Subscriber since Feb 11, 2014
Hacker
 
Posts: 38
Joined: Sat Jan 12, 2013 5:13 am
Has thanked: 3 times
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby romox » Mon Feb 25, 2013 6:36 am

Great tutorial!!!!
but when I tried to run the project, I am getting following error:

Cocos2d.h: No such file or directory.

I tried to add my cocos2d files but no luck.
How can I add cocos2d library to existing project?

Thanks a lot!
romox
Subscriber since Feb 11, 2014
Hacker
 
Posts: 38
Joined: Sat Jan 12, 2013 5:13 am
Has thanked: 3 times
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby charlie » Mon Feb 25, 2013 2:00 pm

romox wrote:Great tutorial!!!!
but when I tried to run the project, I am getting following error:

Cocos2d.h: No such file or directory.

I tried to add my cocos2d files but no luck.
How can I add cocos2d library to existing project?

Thanks a lot!


Hey, the sample project did not have cocos2d included. To add it to the sample project or any other existing project do these steps:

    download cocos2d 2.1 rc0
    in finder browse to the location of the download
    drag the file cocos2d-ios.xcodeproj into your Xcode project.
    then setup your build phases and build settings like it mentions in the tutorial


Oh one more thing the sample project expects cocos2d (via relative path setting) in ~/Downloads/cocos2d-iphone-1.1-RC0 so if you download cocos2d to that direct everything should be good to go.

I'll try to upload a new project today that already has cocos2d setup as an external reference in it.
charlie
Team Member
iOS Tutorial Team Member
 
Posts: 113
Joined: Sun Jan 02, 2011 7:40 am
Has thanked: 3 times
Been thanked: 12 times

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby romox » Mon Feb 25, 2013 4:05 pm

CGPoint viewPoint = ccpSub(centerOfView, actualPosition);

why centerOfView subtract actualPosition, may the result negative? Please explain this part a little bit more, i'll appreciate it very much! thanks a lot!
romox
Subscriber since Feb 11, 2014
Hacker
 
Posts: 38
Joined: Sat Jan 12, 2013 5:13 am
Has thanked: 3 times
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby macpeters » Thu Feb 28, 2013 7:11 pm

Hi, I have been following your tutorials, trying to get accustomed to objective c (more comfortable with c++, c#, javascript, as3, java). You explain stuff well, and cover a lot of great topics.

However, I have noticed some major differences between what the simulator runs, and what an actual device runs. For instance, I have bounds checking and collision happening perfectly in the simulator. On my device, an ipod touch running the latest IOS, top and bottom bounds are non-existent, and collision doesn't happen either.

In your simple flash for IOS tutorial, the text doesn't appear on the device. Everything else works fine. I tried embedding the font, using device fonts, putting text right on the stage. I changed the color of the stage background to ensure the app was updating properly on the device, and still the text fails to appear.
http://www.raywenderlich.com/5249/how-t ... -flash-cs5

:?: How would I go about debugging these sorts of problems?
macpeters
n00b
 
Posts: 1
Joined: Thu Feb 28, 2013 6:55 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby zethak912 » Wed Mar 06, 2013 3:29 pm

Hi, I love your tutorials so far and they've taught me xcode and cocos2d from absolute beginner level so this is probably a problem with me being new to all this but when I run the ipad or iphone simulator I get this message in Xcode:

Code: Select all
 #import <UIKit/UIKit.h>

int main(int argc, char *argv[]) {
   
    @autoreleasepool {
        int retVal = UIApplicationMain(argc, argv, nil, @"AppController");//
        return retVal;
    }
}

BTW this is in main.m which I haven't done anything with (at least not intentionally) except converting it to ARC like you said
Any help would be greatly appreciated, thanks!
EDIT: sorry, didn't realise the actual error won't copy, it says "Thread 1: signal SIGABRT" next to the line with // on the end (That's not there in the code, I just added it to mark the line)
zethak912
n00b
 
Posts: 1
Joined: Tue Mar 05, 2013 3:25 pm
Has thanked: 0 time
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby monkeyboy » Sat Mar 16, 2013 9:41 am

Hi Again..

I'm currently stuck with the debugger stating that it can't find tmw_desert_spacing.png and then says that it cant add it when I go to run the simulator. It even says that the build was successful. I can clearly see it in my resources folder inside the tile game project. I've triple checked the steps in the tutorial and am as sure as I can be that I haven't missed anything. Does anyone know why this might be? Below is the entire debugger output.

2013-03-16 20:28:41.523 TileGame[6115:c07] cocos2d: OS version: 5.1 (0x05010000)
2013-03-16 20:28:41.527 TileGame[6115:c07] cocos2d: GL_VENDOR: Apple Computer, Inc.
2013-03-16 20:28:41.529 TileGame[6115:c07] cocos2d: GL_RENDERER: Apple Software Renderer
2013-03-16 20:28:41.530 TileGame[6115:c07] cocos2d: GL_VERSION: OpenGL ES 2.0 APPLE
2013-03-16 20:28:41.532 TileGame[6115:c07] cocos2d: GL_MAX_TEXTURE_SIZE: 4096
2013-03-16 20:28:41.533 TileGame[6115:c07] cocos2d: GL_MAX_TEXTURE_UNITS: 8
2013-03-16 20:28:41.534 TileGame[6115:c07] cocos2d: GL_MAX_SAMPLES: 4
2013-03-16 20:28:41.535 TileGame[6115:c07] cocos2d: GL supports PVRTC: YES
2013-03-16 20:28:41.536 TileGame[6115:c07] cocos2d: GL supports BGRA8888 textures: YES
2013-03-16 20:28:41.537 TileGame[6115:c07] cocos2d: GL supports NPOT textures: YES
2013-03-16 20:28:41.538 TileGame[6115:c07] cocos2d: GL supports discard_framebuffer: YES
2013-03-16 20:28:41.540 TileGame[6115:c07] cocos2d: GL supports shareable VAO: NO
2013-03-16 20:28:41.541 TileGame[6115:c07] cocos2d: compiled with Profiling Support: NO

2013-03-16 20:28:41.542 TileGame[6115:c07] cocos2d: **** WARNING **** CC_ENABLE_GL_STATE_CACHE is disabled. To improve performance, enable it by editing ccConfig.h

2013-03-16 20:28:41.552 TileGame[6115:c07] cocos2d: cocos2d v2.0.0
2013-03-16 20:28:41.553 TileGame[6115:c07] cocos2d: Using Director Type:CCDirectorDisplayLink
2013-03-16 20:28:41.624 TileGame[6115:c07] cocos2d: animation started with frame interval: 60.00
2013-03-16 20:28:41.629 TileGame[6115:c07] cocos2d: surface size: 1024x768
2013-03-16 20:28:43.045 TileGame[6115:c07] -[CCFileUtils fullPathFromRelativePath:resolutionType:] : cocos2d: Warning: File not found: ../tmw_desert_spacing.png
2013-03-16 20:28:43.045 TileGame[6115:c07] cocos2d: CCTexture2D. Can't create Texture. cgImage is nil
2013-03-16 20:28:43.048 TileGame[6115:c07] cocos2d: Couldn't add image:../tmw_desert_spacing.png in CCTextureCache
monkeyboy
Hacker
 
Posts: 41
Joined: Sat Jul 14, 2012 5:29 am
Has thanked: 7 times
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby monkeyboy » Sun Mar 17, 2013 12:22 pm

Just thought I'd save anyone trying to work this out. I re-did the tutorial from scratch (to the same point so far) and this time it worked. I think the error I made was not browsing to the image required as instructed. Initially I simply typed in the file name instead. I think that xcode needed me to browse. If anyone has a theory I'd love to know. Either way I'm off defcon 1 for now.. I'm a happy noob.. for now..
monkeyboy
Hacker
 
Posts: 41
Joined: Sat Jul 14, 2012 5:29 am
Has thanked: 7 times
Been thanked: 0 time

Re: How To Make a Tile-Based Game with Cocos2D 2.X

Postby mfaizanshaikh » Tue Mar 19, 2013 2:08 pm

You guys are doing a great job. (Y)
mfaizanshaikh
n00b
 
Posts: 2
Joined: Tue Mar 19, 2013 2:07 pm
Has thanked: 0 time
Been thanked: 0 time

Next

Return to Official Tutorials

Who is online

Users browsing this forum: No registered users and 7 guests

cron