See the file LICENSE for the license governing this code.
LevelObject > NonSolid > NonSolids
#pragma once
#include "Headers.h"
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:
health
restores one hitpointhealth2
restores four hitpointsxp
adds one experience pointxp2
adds four experience pointsgold
adds one gold currencygold2
adds four gold currencyclass 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;
};
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.
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.
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.
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;
};
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.
density
(floating point) to specify how many particles per tile.kind
to specify the kind of particles. Affects the movement, arrangement and coloring. Use type random
, smoke
, waterfall
and river
.color
(0-255, 0-255, 0-255) to specify the RGB color of the particles.speed
(floating point) to specify the speed factor of the particles (default is 1
).fade-duration
(floating point) to specify the duration of time in seconds the particles fade in and out.opacity
(0-255) to specify the opacity of the particles. A range can also be used to specify a range of opacity to fade between. Use two integers separated by a dash, like: 24-128
which says the opacity will be a minimum of 24
and maximum of 128
.vector
(two floating points separated by a comma) to specify the vector along which the particles move. When the particles reach the edge of the area, they will teleport to the opposite edge and start again.seed
(integer) to re-seed the random number generator before creating the particles. This ensure the particles will look and act the same given the same random seed.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);
};
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;
};
Core
Object types