Wizard Fu's Cocos2dx Platformer Game Engine v1.0.1

nat@wizardfu.com

See the file LICENSE for the license governing this code.

LevelObject > NonSolid > NonSolids

#pragma once
#include "Headers.h"

Item

A item which the player is granted when sensor contact occurs. There is no chest or other container surrounding the item. It’s out in the open.

Use the tmx object’s name (case insensitive) to specify the kind of item. Current item kinds available:

class Item : public NonSolid
{
	public:
		virtual const char* const profileName() {return "Item";}
		Item();
		virtual ~Item();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void tick(float delta);

	private:
		typedef NonSolid super;
		typedef Item self;
		
		string kind;
		float obtainDistanceSQ;
		Node* sprite3d;
};

Terrain

Marks the rectangular area specified by the object’s x, y, width and height to be a certain type of terrain. A polygon can also be used to delineate the object’s region precisely.

Use the object’s name property (case insensitive) to specify the kind of terrain. Use tmx object property solid to make the terrain a collision region that the player cannot pass through.

Terrain kinds earth, wood and stone are currently placeholders.

Water

The water type will make the player swim through the region. Semi-transparent foreground tiles are one way to create a watery look on top of the water region.

Ladders

The ladder type creates an area the player will cling to and be able to climb. Background tiles can be used to create graphics for the ladder.

Puddle

Affects the player’s walking sounds to be splishes and splashes.

class Terrain : public NonSolid
{
	public:
		enum
		{
			kEarth = 1,
			kWood,
			kWater,
			kPuddle,
			kStone,
			kLadder
		};

		GETTER(int, kind, Kind);
		virtual const char* const profileName() {return "Terrain";}
		Terrain();
		virtual ~Terrain();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void createBody(Physics& physics, void* userData);
		virtual void tick(float delta);
		bool isWithinRegion(const Vec2& point);

	private:
		typedef NonSolid super;
		typedef Terrain self;

		vector<Vec2> polygon;
};

Particles

The rectangular area specified by the tmx object’s x, y, width and height specify a region full of particles. The particles move around, fade in and out and each one has a little character, being maybe bigger or smaller.

Default color, density and movement are meant to simulate fireflies / lightning bugs.

class Particles : public NonSolid
{
	public:
		virtual const char* const profileName() {return "Particles";}
		Particles();
		virtual ~Particles();
		virtual void onEnter();
		virtual void onEnterTransitionDidFinish();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void tick(float delta);

	private:
		typedef NonSolid super;
		typedef Particles self;
		
		enum
		{
			kKindRandom,
			kKindSmoke,
			kKindWaterfall,
			kKindRiver,
			kNumKinds
		};
		
		enum
		{
			kMoteNormal,
			kMoteDistant,
			kMoteBig,
			kNumMoteTypes
		};
		
		struct Mote
		{
			int type;
			Vec2 vec;
			SpriteMirrored* sprite;
			float initial;
		};
		
		vector<Mote> motes;
		int kind, minOpacity, maxOpacity;
		float width, height, speed;

		void stepAnimations(float step);
};

Decal

Displays a sprite at the given location. Use the tmx object property filename to set the sprite’s filename (a spriteframe name will magically work as well). Use the tmx object property hue to change the color of the sprite to the given hue number in the range 0 to 359.

class Decal : public NonSolid
{
	public:
		virtual const char* const profileName() {return "Decal";}
		Decal();
		virtual ~Decal();
		virtual void setProperties(Level& level, ValueMap& dict);
		virtual void tick(float delta);

	private:
		typedef NonSolid super;
		typedef Decal self;
};

Class hierarchy

 
h