Exemple #1
0
Powerup *Powerup::CreatePowerup( const str &className, const str &modelName, Sentient *sentient )
{
	str fullname;
	SpawnArgs args;
	ClassDef *cls;
	Powerup *powerup;


	fullname = "Powerup";
	fullname += className;

	args.setArg( "classname", fullname.c_str() );

	cls = args.getClassDef();

	if ( !cls )
		return NULL;

	if ( !checkInheritance( &Powerup::ClassInfo, cls ) )
		return NULL;

	powerup = (Powerup *)cls->newInstance();

	if ( !powerup )
		return NULL;

	powerup->init( modelName, sentient );

	return powerup;
}
Exemple #2
0
/**
* Static constructor with position and index. Objects should be created with
* this method once dynamic level loading is implemented.
*
* @param	pos	The initial position in world coordinates
* @param	i	The index in the list of power-up metadata
*
* @return  An autoreleased physics object
*/
Powerup* Powerup::create(const Vec2& pos, const PowerupType& t, int i) {
	Powerup* p = new (std::nothrow) Powerup();
	if (p && p->init(pos, t, i)) {
		p->autorelease();
		return p;
	}
	CC_SAFE_DELETE(p);
	return nullptr;
};