Beispiel #1
0
bool Pirate::init()
{
	if (!Sprite::init())
	{
		return false;
	}
	setRunSpeed(50);
	setVaule(20);
	sprite = Sprite::createWithSpriteFrameName("enemyRight2_1.png");
	this->addChild(sprite);
	animationRight = createAnimation("enemyRight2", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationRight, "runright2");
	animationLeft = createAnimation("enemyLeft2", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationLeft, "runleft2");
	animationExplode = createAnimation("explode2", 6, 0.15f);
	AnimationCache::getInstance()->addAnimation(animationExplode, "explode2");

	createAndSetHpBar();
	return true;
}
Beispiel #2
0
bool Thief::init()
{
	if (!Sprite::init())
	{
		return false;
	}
	//初始化怪物的移动速度,左右方向的动画
    setRunSpeed(25);
    setVaule(10);
    sprite = Sprite::createWithSpriteFrameName("enemyRight1_1.png");
    this->addChild(sprite);
    animationRight = createAnimation("enemyRight1", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationRight, "runright1");
    animationLeft = createAnimation("enemyLeft1", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationLeft, "runleft1");
    animationExplode= createAnimation("explode1", 6, 0.15f);
	AnimationCache::getInstance()->addAnimation(animationExplode, "explode1");
    
    createAndSetHpBar();
	return true;
}
Beispiel #3
0
bool Thief::init()
{
	if (!Sprite3D::init())
	{
		return false;
	}
    setRunSpeed(25);
    setVaule(10);
	sprite = Sprite3D::create("orc.c3b");
    this->addChild(sprite);
	sprite->setScale(2.0);
	sprite->setAnchorPoint(Vec2(0,0));
	
	auto animation = Animation3D::create("orc.c3b");
    if (animation)
    {
        auto animate = Animate3D::create(animation);
        bool inverse = (std::rand() % 3 == 0);

        int rand2 = std::rand();
        float speed = 1.0f;
        if(rand2 % 3 == 1)
        {
            speed = animate->getSpeed() + CCRANDOM_0_1();
        }
        else if(rand2 % 3 == 2)
        {
            speed = animate->getSpeed() - 0.5 * CCRANDOM_0_1();
        }
        animate->setSpeed(inverse ? -speed : speed);

        sprite->runAction(RepeatForever::create(animate));
    }
	
    
    createAndSetHpBar();
	schedule(schedule_selector(EnemyBase::changeDirection), 0);
	return true;
}
Beispiel #4
0
bool Thief::init()
{
	if (!Sprite::init())
	{
		return false;
	}
	//初始化小偷的移动速度,左右方向的动画
    setRunSpeed(25);
    setVaule(10);
    sprite = Sprite::createWithSpriteFrameName("enemyRight1_1.png");
    this->addChild(sprite);
    animationRight = createAnimation("enemyRight1", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationRight, "runright1");
    animationLeft = createAnimation("enemyLeft1", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationLeft, "runleft1");
    animationExplode= createAnimation("explode1", 6, 0.15f);
	AnimationCache::getInstance()->addAnimation(animationExplode, "explode1");
    
    createAndSetHpBar();
	//调用定时器schedule刷新自定义的changeDirection函数
	//schedule(schedule_selector(EnemyBase::changeDirection), 0.4f);
	return true;
}
Beispiel #5
0
bool Pirate::init()
{
	if (!Sprite3D::init())
	{
		return false;
	}
    setRunSpeed(50);
    setVaule(20);
    sprite = Sprite3D::create("orc.c3b");
	sprite->setAnchorPoint(Vec2(0,0));
	sprite->setScale(2.0);
    this->addChild(sprite);
    animationRight = createAnimation("enemyRight2", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationRight, "runright2");
    animationLeft = createAnimation("enemyLeft2", 4, 0.1f);
	AnimationCache::getInstance()->addAnimation(animationLeft, "runleft2");
    animationExplode= createAnimation("explode2", 6, 0.15f);
	AnimationCache::getInstance()->addAnimation(animationExplode, "explode2");
    
    createAndSetHpBar();
	schedule(schedule_selector(Pirate::changeDirection), 0);
	return true;
}