Exemplo n.º 1
0
CCSprite* CCSprite::spriteWithFile(const char *pszFileName, CGRect rect)
{
    CCSprite *pobSprite = new CCSprite();
	pobSprite->initWithFile(pszFileName, rect);
	pobSprite->autorelease();

	return pobSprite;
}
Exemplo n.º 2
0
CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture)
{
	CCSprite *pobSprite = new CCSprite();
	pobSprite->initWithTexture(pTexture);
	pobSprite->autorelease();

	return pobSprite;
}
Exemplo n.º 3
0
CCSprite* CCSprite::spriteWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
{
    CCSprite *pobSprite = new CCSprite();
	pobSprite->initWithSpriteFrame(pSpriteFrame);
	pobSprite->autorelease();

	return pobSprite;
}
Exemplo n.º 4
0
//--------------------------------------------------------------------------------------------------------------------
//
//
CCMenu* CreatGameUIWithSprite( CCSprite* pSprite, SEL_MenuHandler callback, int Id, SelectorProtocol *target, CCPoint pos )
{
	CCSprite *spriteNormal = new CCSprite();
	spriteNormal->initWithTexture(pSprite->getTexture());
	spriteNormal->autorelease();
    
	CCSprite *spriteSelected = new CCSprite();
	spriteSelected->initWithTexture(spriteNormal->getTexture());
	spriteSelected->autorelease();
    
	spriteSelected->setColor(ccc3( 100,100,100 ));
    
	CCMenuItemSprite* item1 = CCMenuItemSprite::itemFromNormalSprite(spriteNormal, spriteSelected, target, callback );
	item1->setTag( Id );
        
	CCMenu* pMenu = CCMenu::menuWithItems( item1, NULL);
	pMenu->setPosition( pos );
	return pMenu;  
}
Exemplo n.º 5
0
CCSprite* CCSprite::spriteWithFile(const char *pszFileName)
{
    CCSprite *pobSprite = new CCSprite();
    if (pobSprite && pobSprite->initWithFile(pszFileName))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
	return NULL;
}
Exemplo n.º 6
0
CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture, const CCRect& rect)
{
    CCSprite *pobSprite = new CCSprite();
    if (pobSprite && pobSprite->initWithTexture(pTexture, rect))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
Exemplo n.º 7
0
CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
{
    CCSprite *pobSprite = new CCSprite();
    if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
Exemplo n.º 8
0
CCSprite* CCSprite::create()
{
    CCSprite *pSprite = new CCSprite();
    if (pSprite && pSprite->init())
    {
        pSprite->autorelease();
        return pSprite;
    }
    CC_SAFE_DELETE(pSprite);
    return NULL;
}
Exemplo n.º 9
0
CCSprite* CCSprite::spriteWithTexture(CCTexture2D *pTexture)
{
	CCSprite *pobSprite = new CCSprite();
	if (pobSprite && pobSprite->initWithTexture(pTexture))
    {
	    pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
	return NULL;
}
Exemplo n.º 10
0
CCSprite* CCSprite::create(const char *pszFileName, const CCRect& rect)
{
    CCSprite *pobSprite = new CCSprite();
    if (pobSprite && pobSprite->initWithFile(pszFileName, rect))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
Exemplo n.º 11
0
CCSprite* CCSprite::node()
{
    CCSprite *pSprite = new CCSprite();
    if (pSprite && pSprite->init())
    {
        pSprite->autorelease();
    }
    else
    {
        CC_SAFE_DELETE(pSprite);
    }
    return pSprite;
}
Exemplo n.º 12
0
CCSprite* CCSprite::createWithSpriteFrame(CCSpriteFrame *pSpriteFrame)
{
    CCSprite *pobSprite = new CCSprite();
    if (pSpriteFrame && pobSprite && pobSprite->initWithSpriteFrame(pSpriteFrame))
    {
        pobSprite->autorelease();
        // #resource_scale_fix
        // #HLP_BEGIN
        //pobSprite->setScale(pobSprite->getScale() * CC_CONTENT_SCALE_FACTOR() / CC_RESOURCE_SCALE_FACTOR());
        // #HLP_END
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
Exemplo n.º 13
0
CCSprite* CCSprite::spriteWithBatchNode(CCSpriteBatchNode *batchNode, CGRect rect)
{
	CCSprite *pobSprite = new CCSprite();
	if (pobSprite->initWithBatchNode(batchNode, rect))
	{
        pobSprite->autorelease();
	}
	else
	{
		delete pobSprite;
		pobSprite = NULL;
	}	

	return pobSprite;
}
void ShineEffectAction::doAction(TouchNode *node,bool enable)
{
    CCSize spriteSize;
    if(m_sprites.size() == 0){
        node->getShowSprite(m_sprites,spriteSize);
        for(unsigned int i = 0;i < m_sprites.size();i++){
            BasAreaSkin *skin = dynamic_cast<BasAreaSkin*>(m_sprites[i]);
            if(skin){
                CCSprite *sprite = skin->clone();
                if(sprite){
                    skin->addChild(sprite,-1);
                    sprite->autorelease();
                    sprite->setAnchorPoint(ccp(0.5,0.5));
                    CCSize csize = sprite->getContentSize();
                    sprite->setPosition(ccp(csize.width/2,csize.height/2));
                    m_createSprites.push_back(sprite);
                }
            }
        }
    }
    if(m_sprites.size() == 0){
        return;
    }
    if(m_running == enable)
        return;

    m_running = enable;
    if(m_running){
        float runtime = 0.5;
        for(unsigned int i = 0;i < m_createSprites.size();i++){
            CCSprite *sprite = m_createSprites[i];
            sprite->setScale(1.05);
            CCScaleTo *scaleTo = CCScaleTo::create(runtime,1.2);
            CCFadeOut *fadeOut = CCFadeOut::create(runtime);
            CCScaleTo *scaleBack = CCScaleTo::create(runtime,1.05);
            CCFadeIn *fadeIn = CCFadeIn::create(runtime);
            CCFiniteTimeAction *spawn1 = CCSpawn::create(scaleTo,fadeOut,0);
            CCFiniteTimeAction *spawn2 = CCSpawn::create(scaleBack,fadeIn,0);
            CCAction *action = CCRepeatForever::create((CCActionInterval*)CCSequence::create(spawn1,spawn2,0));
            sprite->runAction(action);
        }
    }else{
        for(unsigned int i = 0;i < m_createSprites.size();i++){
            m_createSprites[i]->stopAllActions();
        }
    }
}
Exemplo n.º 15
0
NS_CC_BEGIN

#if CC_SPRITEBATCHNODE_RENDER_SUBPIXEL
#define RENDER_IN_SUBPIXEL
#else
#define RENDER_IN_SUBPIXEL(__ARGS__) (ceil(__ARGS__))
#endif

CCSprite* CCSprite::createWithTexture(CCTexture2D *pTexture)
{
    CCSprite *pobSprite = new CCSprite();
    if (pobSprite && pobSprite->initWithTexture(pTexture))
    {
        pobSprite->autorelease();
        return pobSprite;
    }
    CC_SAFE_DELETE(pobSprite);
    return NULL;
}
Exemplo n.º 16
0
Extra* Extra::createExtra(CCTexture2D* aTexture)
{
	Extra* pExtra = new Extra();
	pExtra->initWithTexture(aTexture);
	pExtra->setTextureRect(CCRectMake(EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	pExtra->setScale(BRICK_SCALE_FACTOR);
	pExtra->autorelease();

	CCTexture2D* texture = CCTextureCache::sharedTextureCache()->addImage("gfx/bricks.png");
	CCSprite* pShadow = new CCSprite();
	pShadow->initWithTexture(texture, CCRectMake(6*EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	//CCSprite* pShadow= CCSprite::create("gfx/bricks.png", CCRectMake(6*EXTRA_RECT.x, 0, EXTRA_RECT.x, EXTRA_RECT.y));
	if (pShadow)
	{
		pShadow->setScale(0.8f);
		pExtra->addChild(pShadow, TagShadow);
		pShadow->autorelease();
		pShadow->setPosition(ccp(20, -10));
	}

	return pExtra;
}
void MonsterLayer::ccTouchesEnded(CCSet *pTouches, CCEvent *pEvent)
{
    
    CCLog("タッチが離れました");
    
    CCLog("離れるタッチ位置を設定");
    CCTouch* touch = (CCTouch*)pTouches->anyObject();
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
 
    CCSprite* AA = (CCSprite*)this->getChildByTag(103);
    CCSprite* KK = (CCSprite*)this->getChildByTag(113);
    CCSprite* SS = (CCSprite*)this->getChildByTag(123);
    CCSprite* TT = (CCSprite*)this->getChildByTag(133);
    CCSprite* NN = (CCSprite*)this->getChildByTag(143);
    CCSprite* HH = (CCSprite*)this->getChildByTag(153);
    CCSprite* MM = (CCSprite*)this->getChildByTag(163);
    CCSprite* YY = (CCSprite*)this->getChildByTag(173);
    CCSprite* RR = (CCSprite*)this->getChildByTag(183);
    CCSprite* WW = (CCSprite*)this->getChildByTag(203);

    if (!(AA==NULL)) {
        TASP(aF,iF,uF,eF,oF,101,102,103,104,105);
        TASP2(aF, iF, uF, eF, oF, "あ", "い", "う", "え", "お")
        this->removeChildByTag(102,true);
        this->removeChildByTag(103,true);
        this->removeChildByTag(104,true);
        this->removeChildByTag(105,true);

        
    }
    if (!(KK==NULL)){
        TASP(kaF, kiF, kuF, keF, koF, 111, 112, 113, 114, 115);
        TASP2(kaF, kiF, kuF, keF, koF, "か", "き", "く", "け", "こ")
        this->removeChildByTag(112,true);
        this->removeChildByTag(113,true);
        this->removeChildByTag(114,true);
        this->removeChildByTag(115,true);
        
    }
    if (!(SS==NULL)){
      TASP(saF, siF, suF, seF, soF, 121, 122, 123, 124, 125);
         TASP2(saF, siF, suF, seF, soF, "さ", "し", "す", "せ", "そ")
        this->removeChildByTag(122,true);
        this->removeChildByTag(123,true);
        this->removeChildByTag(124,true);
        this->removeChildByTag(125,true);
    }
    if (!(TT==NULL)){
        TASP(taF, tiF, tuF, teF, toF, 131, 132, 133, 134, 135);
        TASP2(taF, tiF, tuF, teF, toF, "た", "ち", "つ", "て", "と")
        this->removeChildByTag(132,true);
        this->removeChildByTag(133,true);
        this->removeChildByTag(134,true);
        this->removeChildByTag(135,true);

        
    }
    if (!(NN==NULL)){
        TASP(naF, niF, nuF, neF, noF, 141, 142, 143, 144, 145);
        TASP2(naF, niF, nuF, neF, noF, "な", "に", "ぬ", "ね", "の")
        this->removeChildByTag(142,true);
        this->removeChildByTag(143,true);
        this->removeChildByTag(144,true);
        this->removeChildByTag(145,true);
        
    }
    if (!(HH==NULL)){
        TASP(haF, hiF, huF, heF, hoF, 151, 152, 153, 154, 155);
        TASP2(haF, hiF, huF, heF, hoF, "は", "ひ", "ふ", "へ", "ほ")
        this->removeChildByTag(152,true);
        this->removeChildByTag(153,true);
        this->removeChildByTag(154,true);
        this->removeChildByTag(155,true);
        
    }
    if (!(MM==NULL)){
        
        TASP(maF, miF, muF, meF, moF, 161, 162, 163, 164, 165);
        TASP2(maF, miF, muF, meF, moF, "ま", "み", "む", "め", "も")
        this->removeChildByTag(162,true);
        this->removeChildByTag(163,true);
        this->removeChildByTag(164,true);
        this->removeChildByTag(165,true);
        
    }
    if (!(YY==NULL)){
        //TASP(yaF, yiF, yuF, yeF, yoF, 171, 172, 173, 174, 175);
        
        
        CCSprite* yaF = (CCSprite*)this->getChildByTag(171);\
        CCSprite* yuF = (CCSprite*)this->getChildByTag(173);\
        CCSprite* yoF = (CCSprite*)this->getChildByTag(175);\

        CCRect rectyaF=CCR(yaF);\
        CCRect rectyuF=CCR(yuF);\
        CCRect rectyoF=CCR(yoF);\
        yaF->retain();\
        yuF->retain();\
        yoF->retain();\
        yaF->autorelease();\
        yuF->autorelease();\
        yoF->autorelease();\
        //TASP2(yaF, yiF, yuF, yeF, yoF, "や", "い", "ゆ", "え", "よ")
        if(rectyaF.containsPoint(location)){
            flickLabel->setString("や");
            CCLog("や");\
        }else if(rectyuF.containsPoint(location)){\
            flickLabel->setString("ゆ");\
            CCLog("ゆ");\
        }else if(rectyoF.containsPoint(location)){\
            flickLabel->setString("よ");\
            CCLog("よ");\
        }
      
        this->removeChildByTag(172,true);
        this->removeChildByTag(173,true);
        this->removeChildByTag(174,true);
        this->removeChildByTag(175,true);
        
    }
    if (!(RR==NULL)){
        TASP(raF, riF, ruF, reF, roF, 181, 182, 183, 184, 185);
        TASP2(raF, riF, ruF, reF, roF, "ら", "り", "る", "れ", "ろ")
        this->removeChildByTag(182,true);
        this->removeChildByTag(183,true);
        this->removeChildByTag(184,true);
        this->removeChildByTag(185,true);
        
    }
    if (!(WW==NULL)){
       
        CCSprite* waF = (CCSprite*)this->getChildByTag(201);
        CCSprite* woF = (CCSprite*)this->getChildByTag(202);
        CCSprite* nnF = (CCSprite*)this->getChildByTag(203);
        CCSprite* barF = (CCSprite*)this->getChildByTag(204);
        
        CCRect rectwaF=CCR(waF);
        CCRect rectwoF=CCR(woF);
        CCRect rectnnF=CCR(nnF);
        CCRect rectbarF=CCR(barF);

        waF->retain();
        woF->retain();
        nnF->retain();
        barF->retain();
        waF->autorelease();
        woF->autorelease();
        nnF->autorelease();
        barF->autorelease();
        //TASP2(yaF, yiF, yuF, yeF, yoF, "や", "い", "ゆ", "え", "よ")
        if(rectwaF.containsPoint(location)){
            flickLabel->setString("わ");
            CCLog("わ");
        }else if(rectwoF.containsPoint(location)){
            flickLabel->setString("を");
            CCLog("を");
        }else if(rectnnF.containsPoint(location)){
            flickLabel->setString("ん");
            CCLog("ん");
        }else if(rectbarF.containsPoint(location)){
            flickLabel->setString("ー");
            CCLog("ー");
        
        this->removeChildByTag(202,true);
        this->removeChildByTag(203,true);
        this->removeChildByTag(204,true);
        this->removeChildByTag(205,true);
        
    }
    
    }



   
    CCLog("ここまでや?");

    
    this->removeChildByTag(102,true);
    this->removeChildByTag(103,true);
    this->removeChildByTag(104,true);
    this->removeChildByTag(105,true);
    this->removeChildByTag(112,true);
    this->removeChildByTag(113,true);
    this->removeChildByTag(114,true);
    this->removeChildByTag(115,true);

    this->removeChildByTag(122,true);
    this->removeChildByTag(123,true);
    this->removeChildByTag(124,true);
    this->removeChildByTag(125,true);

    this->removeChildByTag(132,true);
    this->removeChildByTag(133,true);
    this->removeChildByTag(134,true);
    this->removeChildByTag(135,true);

    this->removeChildByTag(142,true);
    this->removeChildByTag(143,true);
    this->removeChildByTag(144,true);
    this->removeChildByTag(145,true);

    this->removeChildByTag(152,true);
    this->removeChildByTag(153,true);
    this->removeChildByTag(154,true);
    this->removeChildByTag(155,true);

    this->removeChildByTag(162,true);
    this->removeChildByTag(163,true);
    this->removeChildByTag(164,true);
    this->removeChildByTag(165,true);

    this->removeChildByTag(172,true);
    this->removeChildByTag(173,true);
    this->removeChildByTag(174,true);
    this->removeChildByTag(175,true);

    this->removeChildByTag(182,true);
    this->removeChildByTag(183,true);
    this->removeChildByTag(184,true);
    this->removeChildByTag(185,true);

    this->removeChildByTag(202,true);
    this->removeChildByTag(203,true);
    this->removeChildByTag(204,true);
    this->removeChildByTag(205,true);

 
 
    CCCallFuncN* flickDone =
    CCCallFuncN::create(this,callfuncN_selector(MonsterLayer::flickFinished));
    
    runAction(flickDone);
     
    CCLog("指がはなれた");
    
}
////////////フリック入力画面の実装/////////////////////////////////////////////////
void MonsterLayer::ccTouchesBegan(CCSet *pTouches, CCEvent *pEvent)
{
    CCLog("タッチ開始");
    
    
    CCSprite* aF = (CCSprite*)this->getChildByTag(101);
    CCSprite* kaF = (CCSprite*)this->getChildByTag(111);
    CCSprite* saF = (CCSprite*)this->getChildByTag(121);
    CCSprite* taF = (CCSprite*)this->getChildByTag(131);
    CCSprite* naF = (CCSprite*)this->getChildByTag(141);
    CCSprite* haF = (CCSprite*)this->getChildByTag(151);
    CCSprite* maF = (CCSprite*)this->getChildByTag(161);
    CCSprite* yaF = (CCSprite*)this->getChildByTag(171);
    CCSprite* raF = (CCSprite*)this->getChildByTag(181);
    CCSprite* waF = (CCSprite*)this->getChildByTag(201);
    CCRect rectA =aF->boundingBox();
    CCRect rectKa =kaF->boundingBox();
    CCRect rectSa =saF->boundingBox();
    CCRect rectTa =taF->boundingBox();
    CCRect rectNa =naF->boundingBox();
    CCRect rectHa =haF->boundingBox();
    CCRect rectMa =maF->boundingBox();
    CCRect rectYa =yaF->boundingBox();
    CCRect rectRa =raF->boundingBox();
    CCRect rectWa =waF->boundingBox();

    //CCRect rectK =kaF->boundingBox();
    CCTouch* touch = (CCTouch*)pTouches->anyObject();
    CCPoint location = touch->getLocationInView();
    location = CCDirector::sharedDirector()->convertToGL(location);
    
    
    if (rectA.containsPoint(location)) {
        STADC(aF, iF, uF, eF, oF, "iF.png", "uF.png", "eF.png", "oF.png", 102, 103, 104, 105);
       
    }else if(rectKa.containsPoint(location)){
        STADC(kaF, kiF, kuF, keF, koF, "kiF.png", "kuF.png", "keF.png", "koF.png", 112, 113, 114, 115);

    }else if(rectSa.containsPoint(location)){
        STADC(saF, siF, suF, seF, soF, "siF.png", "suF.png", "seF.png", "soF.png", 122, 123, 124, 125);
        
    }else if(rectTa.containsPoint(location)){
        STADC(taF, tiF, tuF, teF, toF, "tiF.png", "tuF.png", "teF.png", "toF.png", 132, 133, 134, 135);
        
    }else if(rectNa.containsPoint(location)){
        STADC(naF, niF, nuF, neF, noF, "niF.png", "nuF.png", "neF.png", "noF.png", 142, 143, 144, 145);
        
    }else if(rectHa.containsPoint(location)){
        STADC(haF, hiF, huF, heF, hoF, "hiF.png", "huF.png", "heF.png", "hoF.png", 152, 153, 154, 155);
        
    }else if(rectMa.containsPoint(location)){
        STADC(maF, miF, muF, meF, moF, "miF.png", "muF.png", "meF.png", "moF.png", 162, 163, 164, 165);
        
    }else if(rectYa.containsPoint(location)){
        CCSprite* yuF = CCSprite::create("yuF.png");
        yuF->setPosition(ccp(yaF->getPosition().x,yaF->getPositionY()+yaF->getContentSize().height));
        this->addChild(yuF,0,173);
        CCSprite* yoF = CCSprite::create("yoF.png");
        yoF->setPosition(ccp(yaF->getPosition().x,yaF->getPositionY()-yaF->getContentSize().height));
        this->addChild(yoF,0,175);
        yuF->retain();
        yoF->retain();
        yuF->autorelease();
        yoF->autorelease();

       

        
    }else if(rectRa.containsPoint(location)){
        STADC(raF, riF, ruF, reF, roF, "riF.png", "ruF.png", "reF.png", "roF.png", 182, 183, 184, 185);
        
    }else if(rectWa.containsPoint(location)){
        CCSprite* woF = CCSprite::create("woF.png");
        woF->setPosition(ccp(waF->getPositionX()-waF->getContentSize().width,waF->getPositionY()));
        this->addChild(woF,0,202);
        CCSprite* nnF = CCSprite::create("nnF.png");
        nnF->setPosition(ccp(waF->getPosition().x,waF->getPositionY()+waF->getContentSize().height));
        this->addChild(nnF,0,203);
        CCSprite* barF = CCSprite::create("barF.png");
        barF->setPosition(ccp(waF->getPositionX()+waF->getContentSize().width,waF->getPositionY()));
        this->addChild(barF,0,204);
        
        woF->retain();\
        nnF->retain();\
        barF->retain();\
        woF->autorelease();\
        nnF->autorelease();\
        barF->autorelease();\
        
        
    }
}