Beispiel #1
0
void Player::showHurtAnimation() {
    
    this->stopAllActions();
    // Set the display frame as long as the player is running
    setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(_profile->spriteHurtName()));
    
    _playerAnimationNode->stopAllActions();
    _playerAnimationNode->setVisible(true); // Make sure the node is visible
    _playerAnimationNode->runAction(_hurtAction);
}
Beispiel #2
0
void RCDPad::processRelease()
{
    setColor(ccc3(255,255,255));
	CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
	setDisplayFrame(cache->spriteFrameByName("d_pad_normal.png"));
	setRotation(0);
	m_pressed = false;
	m_pressedVector = ccp(0,0);
	m_direction = kDPadNoDirection;
}
void AllianceAreaPopupView::reDraw(CCNode* obj){
    if( WorldMapView::instance() == NULL )
        return;
    
    auto addPic = [](CCNode *parent, CCPoint &pt, std::string picName, int tag){
        if(parent->getChildByTag(tag)){
            auto sprite = dynamic_cast<CCSprite*>(parent->getChildByTag(tag));
            sprite->setDisplayFrame(CCLoadSprite::loadResource(picName.c_str()));
        }else{
            auto sprite = CCLoadSprite::createSprite(picName.c_str());
            sprite->setPosition(pt);
            float s = WorldMapView::instance()->m_map->getScale();
            sprite->setOpacity(200);
            sprite->setScale(0.95 * s);
            CCSequence *sequene = CCSequence::create(CCFadeTo::create(1, 50), CCFadeTo::create(1, 200), NULL);
            sprite->runAction(CCRepeatForever::create(sequene));
            parent->addChild(sprite);
        }
    };
    m_showNode->removeAllChildren();
    auto centerPt = m_picNode->getPosition() + ccp(_tile_width, _tile_height / 2);
    float s = WorldMapView::instance()->m_map->getScale();
    centerPt = (WorldMapView::instance()->m_map->getPosition() - centerPt) / s;
    auto mapPt1 = WorldMapView::instance()->m_map->getTilePointByViewPoint(-centerPt);
    currentCenterPt = mapPt1;
    auto mapPt2 = mapPt1 + ccp(-1, 0);
    auto mapPt3 = mapPt1 + ccp(-1, -1);
    auto mapPt4 = mapPt1 + ccp(0, -1);
    auto pt1 = WorldMapView::instance()->m_map->getPosition() + WorldMapView::instance()->m_map->getViewPointByTilePoint(mapPt1) * s;
    auto pt2 = WorldMapView::instance()->m_map->getPosition() + WorldMapView::instance()->m_map->getViewPointByTilePoint(mapPt2) * s;
    auto pt3 = WorldMapView::instance()->m_map->getPosition() + WorldMapView::instance()->m_map->getViewPointByTilePoint(mapPt3) * s;
    auto pt4 = WorldMapView::instance()->m_map->getPosition() + WorldMapView::instance()->m_map->getViewPointByTilePoint(mapPt4) * s;
    bool canRelocateFlag1 = isCanRelocationTile(mapPt1);
    bool canRelocateFlag2 = isCanRelocationTile(mapPt2);
    bool canRelocateFlag3 = isCanRelocationTile(mapPt3);
    bool canRelocateFlag4 = isCanRelocationTile(mapPt4);
    
    std::vector<CCPoint> vector;
    vector.push_back(mapPt1);
    vector.push_back(mapPt2);
    vector.push_back(mapPt3);
    vector.push_back(mapPt4);
    
    if(canRelocateFlag1 && canRelocateFlag2 && canRelocateFlag3 && canRelocateFlag4){
        bool isInSame = isInRelicAndNormalBlock(vector);
        if(!isInSame){
            canRelocateFlag1 = canRelocateFlag2 = canRelocateFlag3 = canRelocateFlag4 = false;
        }
    }
    addPic(m_showNode, pt1, (canRelocateFlag1 ? "green_block.png" : "red_block.png"), 1);
    addPic(m_showNode, pt2, (canRelocateFlag2 ? "green_block.png" : "red_block.png"), 2);
    addPic(m_showNode, pt3, (canRelocateFlag3 ? "green_block.png" : "red_block.png"), 3);
    addPic(m_showNode, pt4, (canRelocateFlag4 ? "green_block.png" : "red_block.png"), 4);
    enableBtn(canRelocateFlag1 && canRelocateFlag2 && canRelocateFlag3 && canRelocateFlag4);
}
Beispiel #4
0
// XXX deprecated
void CCSprite::setDisplayFrame(const char *pszAnimationName, int nFrameIndex)
{
	if (! m_pAnimations)
	{
		initAnimationDictionary();
	}

	CCAnimation *pAnimation = m_pAnimations->objectForKey(std::string(pszAnimationName));
	CCSpriteFrame *pFrame = pAnimation->getFrames()->getObjectAtIndex(nFrameIndex);

	assert(pFrame);

	setDisplayFrame(pFrame);
}
Beispiel #5
0
void CCSprite::setDisplayFrameWithAnimationName(const char *animationName, int frameIndex)
{
	assert(animationName);

	CCAnimation *a = CCAnimationCache::sharedAnimationCache()->animationByName(animationName);

	assert(a);

	CCSpriteFrame *frame = a->getFrames()->getObjectAtIndex(frameIndex);

	assert(frame);

	setDisplayFrame(frame);
}
void CCSpriteButton::setSpriteFrame(CCSpriteFrame *pNormalFrame, CCSpriteFrame *pSelectedFrame)
{
    CC_SAFE_RELEASE_NULL(m_pNormalSprite);
    CC_SAFE_RELEASE_NULL(m_pSelectedSprite);
    if (pNormalFrame)
    {
        m_pNormalSprite = CCSprite::createWithSpriteFrame(pNormalFrame);
        CC_SAFE_RETAIN(m_pNormalSprite);
        setDisplayFrame(m_pNormalSprite->displayFrame());
    }
    if (pSelectedFrame)
    {
        m_pSelectedSprite = CCSprite::createWithSpriteFrame(pSelectedFrame);
        CC_SAFE_RETAIN(m_pSelectedSprite);
    }
}
Beispiel #7
0
bool RCDPad::init()
{
    if (!CCSprite::init()) {
        return false;
    }
    
    m_pressedVector = CCPointZero;
    m_direction = kDPadNoDirection;
    m_pressed = false;
    
    CCSpriteFrameCache *cache = CCSpriteFrameCache::sharedSpriteFrameCache();
    cache->addSpriteFramesWithFile("dpad_buttons.plist");
    setDisplayFrame(cache->spriteFrameByName("d_pad_normal.png"));
    
    return true;
}
Beispiel #8
0
void SushiSprite::setDisplayMode(DisplayMode mode)
{
    m_displayMode = mode;
    
    SpriteFrame *frame;
    switch (mode) {
        case DISPLAY_MODE_VERTICAL:
            frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(sushiVertical[m_imgIndex]);
            break;
        case DISPLAY_MODE_HORIZONTAL:
            frame = SpriteFrameCache::getInstance()->getSpriteFrameByName(sushiHorizontal[m_imgIndex]);
            break;
        default:
            return;
    }
    setDisplayFrame(frame);
}
void CCSpriteButton::ccTouchEnded(CCTouch *touch, CCEvent *event)
{
    //if(m_IsEmitTouchEvent)
    //{
    //    CCScriptEngineManager::sharedManager()->getScriptEngine()->executeEvent(m_nScriptTapHandler,"end");  
    //}
    CCRect rect;
    rect.origin = CCPointZero;
    rect.size = getContentSize();
    if(rect.containsPoint(convertToNodeSpace(touch->getLocation())) && m_pListener && m_pfnSelector)
    {
        (m_pListener->*m_pfnSelector)(this);
    }

    if (m_pNormalSprite)
    {
        setDisplayFrame(m_pNormalSprite->displayFrame()); //»Ö¸´Í¼Ïñ
    }
}
bool CCSpriteButton::ccTouchBegan(CCTouch *touch, CCEvent *event)
{
    m_StartTouchPoint = convertToNodeSpace(touch->getLocation());

    CCRect rect;
    rect.origin = CCPointZero;
    rect.size = getContentSize();
    m_IsEmitTouchEvent= rect.containsPoint(m_StartTouchPoint);
    if(m_IsEmitTouchEvent)
    {
        if (m_pSelectedSprite)
        {
            setDisplayFrame(m_pSelectedSprite->displayFrame());
        }
        return true;
    }
    else  
    {
        return false;
    }
}
Beispiel #11
0
void BossLotteryLight::extinguish()
{
    setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName("bossLottery_light_1.png"));
}
Beispiel #12
0
 Sprite::Sprite(const fzSpriteFrame& spriteFrame)
 : Sprite()
 {
     setDisplayFrame(spriteFrame);
 }
Beispiel #13
0
void Drop::updateImage()
{
	setDisplayFrame(CocosUtils::getSpriteFrameByName(
		getSpriteFrameNameByWater(water)));
}
Beispiel #14
0
void Player::showJumpAnimation() {
    this->stopAllActions();
    setDisplayFrame(CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(_profile->spriteJumpName()));
}
Beispiel #15
0
 void Sprite::setDisplayFrame(const char *spriteFrameName)
 {
     setDisplayFrame(SpriteFrameCache::Instance().getSpriteFrameByKey(spriteFrameName));
 }
Beispiel #16
0
void Portrait::setPortrait(int CharacterName)
{
	m_iCharacterName = CharacterName;
	setDisplayFrame("PORTRAIT", m_iCharacterName);
}
Beispiel #17
0
void Hero::runForceAnimation()
{
	_normalAnimate->stop();
	_normalAnimate = nullptr;
	setDisplayFrame(SpriteFrameCache::getInstance()->spriteFrameByName("seal_downhill.png"));
}