Because we are all using the same
same engine this year,
it is possible for us to post some code samples for 4152. These samples illustrate
some of the technical challenges that you might run into as part of mobile development.
All of these samples come with source code. You are allowed to use the code here as
reference or directly in your own games.
Right now, you will note that the samples page is pretty sparse. That is because we
are still working on writing these samples for you. If you want to help us, that would
be great. If you write a prototype that you think might be of use to the rest of the
class, send it to us and we will post it here.
Important: These samples use our
modifications to Cocos2d-x,
and will not run in a stock Cocos2d-x installation. If you are having trouble setting
up our engine, you may not be able to run these samples.
This is a basic demo of Cocos2D-x that shows off the proper way to use
a Scene Graph (e.g. not like the various tutorials online). It also
shows how to write an application that takes multiple forms of input.
This demo is the one shown in the first day of class.
This demo shows how to use a single Poly2 object to draw multiple textured
2D polygons. In particular, it shows the difference between PolygonNode,
PathNode, and WireNode. In addition, this demo also
shows off how to process multi-touch input.
This demo shows the proper way to use Box2d in Cocos2d-X, decoupled from
the scene graph. This is a port of (part 1 of) Lab 4 from 3152.
This demo uses wireframes to show the physics fixtures. You can toggle
these wireframes by double clicking, or using D on the keyboard.
Yet another Box2D demo, this is a port of (part 3 of) Lab 4 from 3152. It
shows how to use joints to put together a ragdoll. There are two completely
different heirarchies in this demo: the ragdoll physics heirarchy and the scene
graph. Pay close attention to how they communicate.
The last of the Box2d demos, this is a port of (part 2 of) Lab 4 from 3152. It
does not show any Box2 features that you did not already see in the previous
demos. Instead, the primary focus of this demo is character control, showing
how you might control a platformer on a touch device. Press the sides to
go in a direction. Swipe up on the opposite movement side to jump. Finally,
press the bottom of the screen to fire.
This is a reworking of the Rocket Demo. However, instead of hardcoding the level
layout, it reads the level settings from a JSON file (actually two files). This
allows the level to be changed on the fly without recompiling. Everytime you reset
the level, it will reload the level settings from the JSON. However, keep in mind
that when you build the game, it copies the JSON files into the build folder.
Therefore, modifying the original files in Resources will have no effect.
This demo shows off how to do scene transitions in Cocos2d. It has a more advanced
loading screen, and can transition into both the Rocket Demo and the Ragdoll Demo.
The code for those two demos is largely unchanged. This demo just adds an additional
layer on top. To use this demo in your code, you must download the latest copy of
CCDirector from the bug fixes on the Piazza page.