FlareAntlion::FlareAntlion(int addCost, float runSpeed, float hitPoints, Attack* attack, Armour* armour, std::list<Skill*> skills, float mana, float manaRegPerSeconds) : MoveAbleUnit(addCost, "flare_antlion_attack0001.png", 80, runSpeed, hitPoints, attack, armour, skills, mana, manaRegPerSeconds) { initAnimations(); //loading the pictures and set the animations _hitBox = BW_Rect(30, 70); _normalButtonImage = "pFlareAntlion1.png"; _selectedButtonImage = "pFlareAntlion2.png"; _disabledButtonImage = "pFlareAntlion3.png"; _unitName = "Antlion"; _attackEffectSound = "sound_attack_antlion"; }
BW_Sprite::BW_Sprite(std::string image, float height, bool initLable, bool fadeIn) { _doNotKillSprite = false; _isUnit = false; _redColorCounter = 0; _greenColorCounter = 0; _blueColorCounter = 0; _currentColor = ccc3(255, 255, 255); _numMoveAnimationPictures = 0; _numIdleAnimationPictures = 0; _numAttackAnimationPicture = 0; _animationDoDmgPicture = 0; this->_sprite = CCSprite_touch::createWithSpriteFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(image.c_str())); _currentScale = height / getContentSize().getHeight(); _sprite->retain(); this->_sprite->setScale(_currentScale); //standard value if not replaced _hitBox = BW_Rect(getContentSize().getWidth() * _currentScale, getContentSize().getHeight() * _currentScale); this->_image = image; this->_height = height; this->_lookingTo = RIGHT; if (initLable) { _currentLabelScale = 0.8 / _currentScale; _labelHitpoints = Healthbar::create(); _labelHitpoints->setScale(_currentLabelScale); _labelHitpoints->setPosition(CCPoint(_sprite->getContentSize().width / 2, _sprite->getContentSize().height + _labelHitpoints->getHeigth())); _sprite->addChild(_labelHitpoints); } else { this->_labelHitpoints = NULL; _currentLabelScale = 1; } _sprite->setTag(HASACTION); //we set the tag to detect stopped actions if (fadeIn) _sprite->runAction(CCFadeIn::create(0.1)); _movingTo = BW_Point(-124.123, -124.123); //just set a random point //we will never use in the game _moveAnimationSpeed = 0.2; //standard values, should be overwritten at fillMoveAnimationPictures _moveAnimationSpeedUsed = 0.2; //standard values, should be overwritten at fillMoveAnimationPictures _idleAnimationSpeed = 0.2; //standard values, should be overwritten at fillIdleAnimationPictures _attackAnimationSpeed = 0.2; //standard values, should be overwritten at fillAttackAnimationPictures //speed = 2.8f / 14.0f This animation contains 14 frames, will continuous 2.8 seconds. }
BW_Rect BW_Sprite::getRectangular() { float leftDownX = this->getPositionBW().x - (this->getContentSize().getWidth() / 2.0); float leftDownY = this->getPositionBW().y - (this->getContentSize().getHeight() / 2.0f); return BW_Rect(BW_Point(leftDownX, leftDownY), BW_Point(leftDownX + this->getContentSize().getWidth(), leftDownY + this->getContentSize().getHeight())); }