The Ultimate Cocos2d-x Platformer Engine

A cross-platform, parallaxing game engine based on cocos2dx. Includes procedural level generation, scripting, dynamic texturing, realtime multiplayer, virtual economy (in-app purchase) and all the basics like moving platforms, boxes, slopes, water, ladders and artificial intelligence. Write your game code in C++ and level scripts in Javascript. Games built with this kit can be deployed to iOS, Mac, Windows, Android and any of the other platforms supported by cocos2d-x. Various license options are available.

Logic will take you from A to B. Imagination will take you everywhere.
Albert Einstein
Video games are bad for you? That's what they said about rock-n-roll.
Shigeru Miyamoto

Wizard Moon: The Demo Game

Playing the demo game is a great way to get an idea of what the platformer game engine can do. We make available the Mac and Windows versions because they are easiest to obtain (and maintain).

Cross-platform

It's becoming more and more critical to a game's success to publish on multiple platforms. With the platformer engine it's just as easy to deploy to Steam as it is the iStore, Google Play or Ouya. Using the same C++ codebase, you can produce working binaries for Mac, Windows, Linux, iOS, Android and Windows Phone. You can develop in Xcode, Visual Studio and Eclipse.

Part of the magic involved in cross-platform development is handling input in a flexible way. There's touch input, keyboard input, mouse input, controller input and even networked multiplayer input. The trick is in getting them all to feel just right. Our goal for the example game was to get the input to feel like a controller even on touch screens. To this end we set up a customizable nintendoesque button scheme. We also added support for gamepads, joysticks and other controllers so you can play your game couch-style. See the documentation file on Input.h for details.

Getting a game to run well on multiple platforms -- let alone feel right -- is no small achievement. Countless hours have gone into getting that "just right" feeling and years of experience developing cross-platform have been relied upon.

Procedural Texturing

What new-school game engine would be complete without procedurally generated textures?

The Level object has the power to generate pixel-perfect textures using sine waves and lots of randomness.

Physics

Another one of those things that makes a game "just right" is physics. Since that is something unique to each game, we've built in the ability to swap physics engines. The default is Box2d, but you can use another or roll your own simply by changing the cpp file. See the documentation file Physics.h for details.

The platformer engine has support for water, ladders, platforms, boxes, slopes, jump-pads, one-way tiles and more. See: Terrain.h.

IAP

In-app purchases are a great way to make money with games. We've included Soomla, a cross-platform purchasing and virtual economy framework. See Store.h for details.

What's a virtual economy? It's a way for your game to keep inventory of and allow the purchasing of virtual currencies. Your game might have a currency called "gold" which allows the purchasing of certain kinds of items and a currency called "silver" which allows purchasing other things. Soomla helps you keep track of everything and enables you to easily add purchasing to your game.

Realtime Networked Multiplayer

The platformer game engine is built with realtime networked multiplayer in mind. The time step is fixed, object updates have been separated into tick and animate, integer math is used for game state variables and determinism is possible.

The example game enables a special realtime multiplayer mode on iOS and Android that uses Nextpeer. Two opponents are thrown into an arena and allowed to battle it out. A BotPlayer object takes over for either opponent if no input is detected. See Multiplayer.h for details.

Powerful Scripting

Javascript files can be triggered at the beginning of levels, when enemies die, or when the player reaches a certain place. The script has complete control over the cocos2d-x game engine, so not only can you create story events, but you can do just about anything you would do in C++. In fact, we've extended the Javascript with a few bindings of our own that make scripting story elements easier. You can find level objects easily, lock / unlock the input, start a line of dialogue, and easily run an animation from a character's profile.

Player, Characters, Items and other Objects

The Player object implemented for the demo game can walk, turn, jump, fall, land, crouch, stand up, hang from edges, aim in eight directions, fire projectiles, swim, climb ladders, step up stairs, be given items, perform special animations, get knocked out and knocked back.

Each Character, Item, all the objects in the game have a Profile property list which parses a format string to load many spriteframes into an animation, preloads sound effects needed by the object and specifies any attributes for the default object class. You can setup a ninja property list, for example, that auto-loads a walking animation with 8 frames, 7 different sound effects and specifies that ninjas have 10 hit points and deal 2 damage by default. Attributes can also be overriden by TMX object properties. So creating a ninja object and giving it an hp property of 15 will override the default 10 hitpoints.

Object types: Player, Item, Chest, Platform, JumpPad, Box, Slope, Door, Debris, Fire, Decal, Particles, Terrain (water, ladders, etc.), MagicMissile, Bone, EnergyBall, Squirrel, Blob, Knight, Jellyfish, Mage, Skeleton, Sasquatch and BotPlayer.

Object properties: x, y, width, height, name, id, tag, scale, z, background, hp, damage, music, onDeath.

TMX Map Files

At the heart of the platformer engine are TMX tiled maps. Each level is a separate map and they are stitched together by an overall world plist file. Maps are drawn with the open-source Tiled map editor and parsed into the game using cocos2dx' TMXTiledMap class. The platformer engine extends on the TMX format by providing map properties, layer properties and a host of objects with their own properties as well.

Map properties decide many factors of how the platformer engine displays and runs the level. You can switch on/off dynamic texturing algorithms, specify the song or ambience to play during the level, change the color of the layers, specify backgrounds / foregrounds to parallax and even cue scripts to run at certain trigger points. For details, see the documentation for Level and LevelObject.

Map properties: music, texturing, spritesheet, hue, mirror, bg, fg, script-event and sound-loop.

Layer properties: solid, z, parallax and oneway.

Procedural Level Generation

Drawing maps in Tiled is fun, but wouldn't it be cool if they could be procedurally generated? We've built a level generator into the engine. In the world plist you can specify that an area has 10 different levels for example, and you always want level 1 to load Home.tmx. The other 9 are magically generated. In this way you can mix and match dynamic level generation with traditional TMX files. You can also use entirely traditional TMX files or entirely dynamic levels. It's your choice.

Procedural area generation creates a random overall structure of levels that connect together sort of like patchwork, only the patches can be all sorts of rectangles, not just squares. The area generator ensures all the exits points line up, then decides on which levels to put quest items, powerups, enemies, save points, and bosses.

 

Contents of the Download

  • Complete C++ source code to the platformer engine
  • Over 200 pages of literate-style documentation.
  • Project files for Xcode, Visual Studio, Eclipse and commandline make. (Deploy to iOS, Mac, Android, Windows and more platforms.)
  • Cocos2d-x (the cross-platform game engine) source code, projects and prebuilt libraries.
  • Additional libraries: Soomla (in-app purchasing), Nextpeer (multiplayer) and OIS (gamepad).
  • Complete C++ source code, level files, Javascript level scripts, artwork, sound effects and music for the demo game.
  • A PDF copy of our book: How to Make a Cross-platform Platformer Game.
  • A bonus art package with thousands of royalty-free sprites, backgrounds & textures.

 

License Options

We offer a few different licensing options depending on what kinds of games you want to publish. Licenses are upgradeable at any time. Discounts are available for students and those who agree to post a review. Contact us for more info.

Licenses are backed by a 14-day 100% money-back guarantee. If you are not satisfied, please contact us for a full refund.

Non-commercial LicensePublish 1 non-commercial / free game
$99
Indie LicensePublish 1 commercial game
$299
Developer LicensePublish up to 10 commercial games
$1499

Artwork, sound effects, ambience, music and other art assets for the demo game WizardMoon are included, but remain the copyright of Wizard Fu, Inc.

We donate 10% of royalties to charities such as JustGive.org and CFCA.

Requirements

Mac development requires Mac OS X and Xcode 5.1 or newer. Mac OS X and Xcode are free.

Windows development requires Windows 7 or newer and Visual Studio 2012 or newer. There is a free version of Visual Studio available.

Android development requires the freely-available Android SDK and NDK.

Linux development requires Linux. 'Nuff said.

FAQ

Q: If I purchase a license, how long will I get updates from your engine?

A: For the lifetime of the engine.

Q: Is there a difference in the source codes / binaries for the different licenses?

A: No. The source code is exactly the same.

Q: Do you have a link for a roadmap on what we will be expecting new features next?

A: Not yet. But the next thing on the list is a custom, pixel-perfect physics engine that can replace Box2d by switching a single define.

Q: What design does this engine use for the implementation? Is it entity / component based design or OOP?

A: Check out the documentation. It gives the actual header files for every class in the engine. It's mostly OOP with a few component-based classes. In future updates, entity/component-based design will be used more and more.

Q: If I purchase the 'non-commercial' license, would the bonus art package be allowed to use commercially?

A: Yes. The bonus art is all royalty-free for whatever use you would like.

Q: Do you have a preview image of the bonus art package?

A: The bonus art is by Reiner's Tilesets. Check out his website for examples. In future releases, the engine will provide links to other royalty-free art. Here's a link to get you started.

Changelog

Version 1.0.1 - August 24, 2014

  • Added "Find opponent" to multiplayer menu on Android. Cross-platform realtime multiplayer enabled.
  • Chests now require a cooldown before taking subsequent hits.
  • Fixed runtime error due to language codes other than "en".
  • Moved dpad and A/B button positions to Game and fixed a crash bug after playing a multiplayer match.
  • Linking with xinput.lib on Windows.

Version 1.0.0 - August 22, 2014

  • Created a makefile in Raw/Icons which allows you to easily update the icon files for all platforms. See the README for details.
  • "Find opponent" added to demo game's multiplayer menu on iOS / Android.
  • Added grass to procedurally generated textures.
  • Improved logic for ladders so pressing up is required to climb and pressing jump makes the player fall.
  • Scripts automatically save an id so they are only played once.
  • Chests use a more reliable method for granting items to the player based on distance.
  • Added Soomla store example code.
  • Hooked up gamepad support for Windows.
  • Fixed no-parallax backgrounds for large screen retina displays.

Version 0.9.10 - August 20, 2014

  • Fixed missing prebuilt lib/cocos2d/x/script directory.

Version 0.9.9 - August 19, 2014

  • Initial public release.
  • Upgraded to Cocos2d-X 3.2 / Cocos2d-JS 3.0 RC2.
  • Supported platforms: iOS, Mac, Windows, Android.
  • Objects: Player, Item, Chest, Platform, JumpPad, Box, Slope, Door, Debris, Fire, Decal, Particles, Terrain (water, ladders, etc.), MagicMissile, Bone, EnergyBall, Squirrel, Blob, Knight, Jellyfish, Mage, Skeleton, Sasquatch and BotPlayer.
  • Added realtime multiplayer support.
  • Added IAP / virtual economy support.
  • Added gamepad support for Windows / Mac / Linux.
  • Added javascript support.
  • Abstracted physics engine.