Cocos2d Tips: Design Game Objects for your game

Keep your game classes organized and logically ordered. Create a GameObject class, a GameCharacter class and then subclass these. Its important to keep your Game Objects ordered as well as your code.  The more you order your objects, the cleaner your code will be as well.  A GameObject is anything used in a game from labels to sprites to power ups. Its important to create a base class for all objects because, as a simple example, you want to be able to constrain all game objects to your screen.  Its not unthinkable to believe that at some point you might inadvertently cause a game object to be pushed off screen.… Read More

Continue Reading

Cocos2d Tips: Scrolling, Parallax and wider levels

Wider Levels & Scrolling When you create a game in Cocos2d, your screen measures 960 pixels wide on iPhone4+ and 2048 on iPad. If we want him to move farther to the right then we need to make the level bigger.  Normally we set: levelSize = screenSize; But now we basically wish to make: levelSize = CGSizeMake(screenSize.width * 2.0f, screenSize.height); // levelSize code What we are doing is changing our scene levelSize to 2x the screenSize. Our level is now twice as big and we have a GameScene, which contains a GameplayLayer & a BackgroundLayer with some background image.  We want to add a layer that will scroll in the opposite… Read More

Continue Reading

Cocos2d Tips: Transitioning between game screens

Let’s learn how to create menu for a cocos2d game and how to move between a menu, the game scene, a level complete scene etc. Eventually your game will grow and you will have to create a clear structure to keep everything organized. As you can see, as with any app, the AppDelegate is the first object called. As such, it is the entry point to your game and will call the very first scene of your game. This means the first scene should probably the main menu which welcomes the user to the game and presents him with options. As you can see from the Cocos2d tips “Creating a… Read More

Continue Reading

iOS App or Cocos2d Game Design – Grand Scheme

A lot of programmers that are entering the iOS application or Cocos2d game arena are somewhat confused about the overall scheme of things. They can’t see the forest for the trees. I’m a very visual learner myself, which actually makes me a rather bad programmer. Actually it makes me a bad programmer because I’m slow to pick stuff up. I need to see the big picture and then dive into the details, not the other way around. So I put together a simple image, for visual learners like myself, to understand how things operate. At this moment its a very simple image. I intend to update it constantly in order… Read More

Continue Reading

Cocos2d Tips: Creating a Menu

You can create a menu by creating label items or image items and passing them to a CCMenu object. A typical MainMenuScene.m file might look like this: -(void)playScene:(CCMenuItemFont*)itemPassedIn { if ([itemPassedIn tag] == 1) { [[GameManager sharedGameManager] runSceneWithID:kIntroScene]; } else if ([itemPassedIn tag] == 2) { [[GameManager sharedGameManager] runSceneWithID:kSecondScene]; } else if ([itemPassedIn tag] == 3) { [[GameManager sharedGameManager] runSceneWithID:kThirdScene]; } else { CCLOG(@”Unexpected item. Tag was: %d”, [itemPassedIn tag]); } } -(void)displayMainMenu { CGSize screenSize = [CCDirector sharedDirector].winSize; if (sceneSelectMenu != nil) { [sceneSelectMenu removeFromParentAndCleanup:YES]; } // Main Menu CCMenuItemImage *playGameButton = [CCMenuItemImage itemWithNormalImage:@”TapMeToPlay.png” selectedImage:@”TapMeToPlay.png” disabledImage:nil target:self selector:@selector(displaySceneSelection)]; CCMenuItemImage *optionsButton = [CCMenuItemImage itemFromNormalImage:@”someImage.png” selectedImage:@”someImage.png” disabledImage:nil target:self selector:@selector(showOptions)]; mainMenu =… Read More

Continue Reading

iOS Indie Developer/Programmer Evolution

These are just random thoughts on what I believe are the pros and cons of coding an app vs a game.  The reason why I am writing this is actually because I find myself in the same predicament.  I’ve been coding crap for the past 3 years and I believe its time to make something “significant”. At first I thought, I’ll code a bunch of apps and even though they might not be Top Pick apps, they will be enough.  Even if they only make about $5-$10 a month,  I may be reaping $100 a month which sounds cool.  I even got into the whole iAds thing and thought it… Read More

Continue Reading

Cocos2d Tips: Animations and image sizing

So you have some art but don’t know how to properly size it for the iPad or iPhone in their 2 versions (retina and non-retina display)! Let’s learn about image sizing and how to use these images in animations for your game objects (player, enemies, power ups or simple eye candy). Before we even get into creating animations, we need to clear up the sizing issue.  Currently there are 4 screen sizes: iPhone NonRetina = 480 x320 iPhone Retina = 960 x 640 iPad NonRetina = 1024 x 768 iPad Retina = 2048 x 1536 This means that when creating art for a game, you will go bonkers sizing images… Read More

Continue Reading

Cocos2d Tips: How to design a game coding strategy

Know you know quite a bit, enough to make a game. Do you know how and where to start? Let’s look at how to start coding your action layer, what code to put in what methods and how to keep your update method clean and tidy. When I started coding, and unfortunately most of my current projects are still coded that way, I simply opened up Xcode and started coding.  iOS apps are a bit better because you can use the “hooks” methods they come with such as viewDidLoad and cellForRowAtIndexPath etc.  Games are a bit more confusing because you are given an empty slate.  At least in Cocos2d you… Read More

Continue Reading

Cocos2d Games: PhysicsEditor & TexturePackerPro

Getting an app from idea to finished product is quite a drawn-out process.  As programmers we rarely accept the fact we need help, but thats when tools like these come in.  Tools like PhysicsEditor & TexturePacker are perfect for speeding up the development process of games so that you can focus on the tasks that matter most, the tasks that make a game a winner; game logic. Pick up these tools today, trust me, your expectations will be more than surpassed! http://www.texturepacker.com – The sprite sheet creator turns chaos into order http://www.physicseditor.de – Edit your physics shapes with ease

Continue Reading