trigger.h

来自「一个symbian 冒险游戏代码」· C头文件 代码 · 共 49 行

H
49
字号
#ifndef _TRIGGER_H
#define _TRIGGER_H


#include "FixVec2.h"
#include "MapObject.h"
#include <lang/String.h>


class MapObject;


class Trigger
{
public:
	enum Flags
	{
		FLAG_ENABLED	= 1,
	};

	FixVec2	block;
	int		flags;
	char	name[32];

	Trigger() : block(Fix(0),Fix(0)), flags(FLAG_ENABLED) {name[0]=0;}

	bool	enabled() const;
	bool	isCollision( MapObject* o ) const;
};


inline bool Trigger::enabled() const						
{
	return 0 != (FLAG_ENABLED & flags);
}

inline bool Trigger::isCollision( MapObject* o ) const	
{
	if ( !enabled() ) return false; 
	const int x = block.x.toInt();
	const int y = block.y.toInt();
	if ( ( x < 0 ) && ( y < 0 ) ) return true;
	FixVec2 b = o->blockPosition(); 
	return b.x.toInt() == x && b.y.toInt() == y;
}


#endif // _TRIGGER_H

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?