Tips To Build iOS Games With Cocos2d

December 5, 2017 Shashank Mehrotra 456 Views

While developing a mobile game, there’s a lot that you could go wrong with. You could easily mess up with the size of your game or the way it looks on various screens. But with Cocos2d and our help, you can’t possibly go wrong! We have gone into depths about the game engine and why you should give it a try in a previous blog. Do check it out before you read this blog.

Now that we’re on the same page, let’s look at a few important tips to keep in mind while building iOS games with Cocos2d:

Separate Game Mechanics From Game Content

For many people, it gets a bit difficult to even realize the difference between game mechanics and game content. So let me explain the difference first. Consider one of my favorite games as a child, Contra Force. I have spent countless hours playing it with my cousin since it was one of the few games back then which had the feature of playing co-op. If you think about its fourth mission wherein we were supposed to fight the people on the airplane, the design of the level and the story behind the level and the game is what built up the game content, while the displacement due to the force of the wind built up the game mechanics. I hope this cleared things out. You can see it in all the games involving physics in any form(Mario’s jump, Kamen’s bird, oh I could go on for hours!)
One of the many things you could do to prevent yourself from confusing the two is that you could model the mechanics in code. What this essentially means is that the code of the mechanics should be separate and the code of the levels should be separate. This comes naturally to most coders who have had the habit of using functions very often before getting into game development.

Be Wary of Different Screen Sizes

As a beginner using Android Studio for game development, I always used to build games for my mobile phone so that I could test it better. What I did wrong was that since I made them keeping my mobile’s screen size in mind, I didn’t think about how they looked on other mobile phones. Later when I checked them on my friend’s mobile phone, the games looked weird.
I’m not the only one who has faced this problem, you might have faced this issue as well. So, for beginners and people who miss out on this, here’s a tip: be wary of different screen sizes. Try not to hard code your assumptions and always place objects in a relative manner. In Cocos2d, the content size property can be used to tackle this problem. Use it wisely to ensure that your iOS game looks good on all screen sizes.

Save Time With Composition

Every game has some non-playable characters(NPCs). Each NPC has their own set of traits. Taking Contra as a reference again, you might notice that every enemy has their own way of attacking you. There’s a guy who would keep shooting and walking left. Then there’s a guy who would stick to his spot and crouch and shoot missiles at you. Then there’s…(you get the point!)
So if you were to code each enemy writing down each action of theirs, you would be wasting a lot of time since these characters have at least one action in common, attacking you. Instead of writing these actions separately for every character, you could simply write a function which would contain this action. Now you can use it in every character by calling that function in the character’s block. You can do the same for every action and reuse the function wherever necessary. If you’re wondering whether it can be done using inheritance as well, you can, but there would be limitations to that especially when you have a lot of characters. Using functions instead would save you a lot of time.

If you wish to save more time in making your iOS game, ask BrainMobi to make your game. We are a leading mobile game development company with a lot of valuable experience which reflects in the games we make. Send us your requirements at sales@brainmobi.com to get a free quote!

Share This

About the author

shashank Shashank is a Marketing & User Experience Specialist by profession and is also a member of founding team at BrainMobi. He is passionate about brands, marketing communication, mobile apps strategy and user experience design. He is responsible for helping BrainMobi develop and grow its mobile business in USA, UK, UAE, SE Asia, Middle East and Europe. His articles have been published by Smashing Magazine, Appindex, Clutch, AppFutura and many others.

GREAT THINGS NEED
GREAT MINDSET

Finding a mobile application development company to build your custom app?
Hire app developers from BrainMobi to fulfil your app development requirements.
Select BrainMobi for better decision making for your business.

GET IN TOUCH