Wizard Fu's Cocos2dx Platformer Game Engine v1.0.1


See the file LICENSE for the license governing this code.

LevelScene is a scene containing the current Level and HUD items like Player and Enemy hitpoints, dialogue text, the dpad and buttons (mobile platforms) and experience bar. The LevelScene listens for touch events and sends the data to the Input class.

#pragma once
#include "Headers.h"

class LevelScene : public Layer
		typedef Layer super;
		typedef LevelScene self;

		virtual ~LevelScene();

The Level.

		GETTER(Level*, level, Level);

Static function to get the current LevelScene.

		static self* getInstance();

Load the given area and level.

		void loadLevel(int areaNum = -1, int levelNum = -1);

Handle onEnter, creating sprites.

		virtual void onEnter();

Animate the level scene.

		void animate(float delta);

Show / hide hit points.

		void showHitPoints(int playerIndex, int hp, int maxHP);
		void hideHitPoints();

Show / hide experience.

		void showXP(int playerIndex, long xp);
		void hideXP();

Show / hide gold.

		void showGold(int playerIndex, long gold);
		void hideGold();

Animate a line of dialogue.

		void animateDialogue(const string& text, LevelObject& actor);

Returns a new scene.

		static Scene* scene();

Check input.

		void checkInput();

Shows the level complete screen.

		void showLevelComplete(bool success);

Fades the screen in or out and returns the fading color layer.

		LayerColor* fade(bool out);

Removes the fade color layer.

		void removeFadeLayer();

Moves the current fade layer to a new position.

		void moveFadeLayer(const Point& position);


		class HitPoint : public Node
				int id;
				Sprite* q[4];
				void createSprites(int p, int max);

				GETTER_SETTER(Vec2, origin, Origin);
				HitPoint(int id);
				void setPoints(int p, int max);

		vector<HitPoint*> hitPoints[2];
		static self* currentLevelScene;
		Sprite* xpSprite, *xpHolder;
		Label* xpLabel;
		Sprite* goldSprite, *goldHolder;
		Label* goldLabel;
		Sprite* buttons[kNumberOfButtons];
		string dialogueText;
		LayerColor* dialogueLayer;
		Label* dialogue;
		Sprite* dialogueLine;
		double dialogueStartTime, dialogueFinishTime;

		void refreshXPLabel();
		void animateHideHitPoints();