Exemplo n.º 1
0
bool Enemy::init(char* name,int type)
{
    isActed=false;
    this->type=type;
    createAnimate(name, 10);
    Size si=Director::getInstance()->getWinSize();
    if(type==0){scoreValue=50;}
    else if(type==1){scoreValue=100;}
    else if(type==2){scoreValue=200;}
    
    this->setPosition(Point(CCRANDOM_0_1()*si.width, si.height+this->getContentSize().height));
    
    this->scheduleUpdate();
    
    return true;
}
Exemplo n.º 2
0
bool Coin::init(){
	if(!Node::init()){
		return false;
	}

	//缓存池
	auto frameCache = SpriteFrameCache::getInstance();
	frameCache->addSpriteFramesWithFile("parkour.plist","parkour.png");

	auto sprite = Sprite::createWithSpriteFrameName("coin0.png");

	//绑定
	setSprite(sprite);
	//执行动作
	getSprite()->runAction(createAnimate(frameCache));
	//绑定刚体
	initBody();

	return true;
}