Wizard Fu's Cocos2dx Platformer Game Engine v1.0.1


See the file LICENSE for the license governing this code.

LevelObject > Projectile

Projectile is a subclass of LevelObject representing a projectile, something that flies through the air with a given velocity, may or may not be affected by gravity, may or may not collide with the Level or other LevelObjects and may or may not explode on impact. Contains a vector, speed, damage, target class, etc.

#pragma once
#include "Headers.h"

class Projectile : public LevelObject
			kInfinite = -99999,
		virtual const char* const profileName() {return "Projectile";}
		virtual ~Projectile();

The vector this projectile will move along.

		GETTER(Vec2, vector, Vector);
		void setVector(const Vec2& v);

Speed of the projectile in meters per second.

		GETTER_SETTER(float, speed, Speed);

The number of hits a projectile can give before expiring.

		GETTER_SETTER(float, hp, HP);

Amount of time this projectile will last.

		GETTER_SETTER(float, lifeTimer, LifeTimer);

Delay until the projectile is launched.

		GETTER_SETTER(float, delayTimer, DelayTimer);

The object that launched the projectile.

		GETTER_SETTER(LevelObject*, attacker, Attacker);

Whether or not the projectile will impact any target, or a specific target class.

		GETTER_SETTER(bool, attackAnyTarget, AttackAnyTarget);

The class name of the object that this projectile should seek to impact.

		GETTER_SETTER(string, targetClass, TargetClass);

Set the objects properties.

		virtual void setProperties(Level& level, ValueMap& dict);

Finds a target object.

		virtual LevelObject* findTarget();

Launches the projectile.

		virtual void launch();

Tick the projectile.

		virtual void tick(float delta);
		virtual void animate(float delta);

Called when the projectile is destroyed.

		virtual void onDestroy();

Private / Protected

		typedef LevelObject super;
		typedef Projectile self;
		Vec2 lastPos, motionCooldown;
		float hitTimer;

Class hierarchy