コード例 #1
0
// Used with box2d style velocity (m/s where m = 32 pixels), but box2d is not required
void CCParallaxScrollNode::updateWithVelocity(CCPoint vel, float dt)
{
	vel = ccpMult(vel, PTM_RATIO);
//	CCLog("count: %i", _scrollOffsets->count());
    CCObject* object;
    CCARRAY_FOREACH(_scrollOffsets, object)
    {
        CCParallaxScrollOffset* scrollOffset = dynamic_cast<CCParallaxScrollOffset*>(object); 
		CCPoint relVel = ccpMult(scrollOffset->getRelVelocity(), PTM_RATIO);
		CCPoint totalVel = ccpAdd(vel, relVel);
		CCPoint offset = ccpCompMult(ccpMult(totalVel, dt), scrollOffset->getRatio());
        
        CCNode *child = scrollOffset->getTheChild();
		child->setPosition(ccpAdd(child->getPosition(), offset));
		
		if ( (offset.x < 0 && child->getPosition().x + child->getContentSize().width < 0) ||
            (offset.x > 0 && child->getPosition().x > _range.width) ) {
			child->setPosition(ccpAdd(child->getPosition(), ccp(-SIGN(offset.x) * fabs(scrollOffset->getScrollOffset().x), 0)));
		}
		
		// Positive y indicates upward movement in cocos2d
		if ( (offset.y < 0 && child->getPosition().y + child->getContentSize().height < 0) ||
			(offset.y > 0 && child->getPosition().y > _range.height) ) {
			child->setPosition(ccpAdd(child->getPosition(), ccp(0, -SIGN(offset.y) * fabs(scrollOffset->getScrollOffset().y))));
		}
	}
コード例 #2
0
ファイル: CShopLayer.cpp プロジェクト: JoeHu/magicpet
//------------------------------------
//
//
void CShopLayer::onEnter()
{
	CCXMLLayer::onEnter();

	LoadPlist("gameshop.plist");

	const char *MenuButton[] =
	{
		"button_back",
        "button_1",
        "button_2",
        "button_3",
        "button_4",
        "button_91"
	};

	for( int i = 0; i < 6; i++ )
	{
		CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( MenuButton[i] );
		CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(CShopLayer::menuCallback), i, this, pSprite->getPosition() );
		addChild( pMenu, pSprite->getZOrder() );
		removeChild( pSprite, true );
	}
    
    CCNode *pNode = GetXMLNodeFromKey( "t2dSceneObject_money_1" );
    
    char buffer[32];
    sprintf( buffer, shop_1[g_iCurLanguageIndex], 1 );
    string utf8;
	CChineseCode::GB2312ToUTF_8( utf8, buffer, 256 );
    
	CCLabelTTF *plabelName = CCLabelTTF::labelWithString(buffer,  kFontSystem[FONT_MED].fontName,kFontSystem[FONT_MED].fontSize);
	addChild(plabelName,99);
	plabelName->setPosition( pNode->getPosition() );
    
    
    pNode = GetXMLNodeFromKey( "t2dSceneObject_money_2" );
    
    sprintf( buffer, shop_1[g_iCurLanguageIndex], 4 );
	CChineseCode::GB2312ToUTF_8( utf8, buffer, 256 );
    
	plabelName = CCLabelTTF::labelWithString(buffer,  kFontSystem[FONT_MED].fontName,kFontSystem[FONT_MED].fontSize);
	addChild(plabelName,99);
	plabelName->setPosition( pNode->getPosition() );
}
コード例 #3
0
    void CCParallaxScrollNode::updateWithVelocity(const CCPoint &vel, float dt) {
        CCSize screen = CCDirector::sharedDirector()->getWinSize();
        
        CCPoint vel2 = ccpMult(vel, PTM_RATIO);
        
        for (int i=scrollOffsets->num - 1; i >= 0; i--) {
            CCParallaxScrollOffset *scrollOffset = (CCParallaxScrollOffset*)scrollOffsets->arr[i];
            CCNode *child = scrollOffset->getChild();
            
            CCPoint relVel = ccpMult(scrollOffset->getRelVelocity(), PTM_RATIO);
            CCPoint totalVel = ccpAdd(vel2, relVel);
            CCPoint tmp = ccpMult(totalVel, dt);
            CCPoint offset = ccpCompMult(tmp, scrollOffset->getRatio());

            
            child->setPosition(ccpAdd(child->getPosition(), offset));
            
            if ( (vel2.x < 0 && child->getPosition().x + child->getContentSize().width < 0) ||
                (vel2.x > 0 && child->getPosition().x > screen.width) ) {
                
                child->setPosition(ccpAdd(child->getPosition(), ccp(-SIGN(vel2.x) * fabs(scrollOffset->getScrollOffset().x), 0)));
            }
            
            // Positive y indicates upward movement in cocos2d
            if ( (vel2.y < 0 && child->getPosition().y + child->getContentSize().height < 0) ||
                (vel2.y > 0 && child->getPosition().y > screen.height) ) {
                child->setPosition(ccpAdd(child->getPosition(), ccp(0, -SIGN(vel2.y) * fabs(scrollOffset->getScrollOffset().y))));
            }
        }
    }
コード例 #4
0
 void CCParallaxScrollNode::updateWithYPosition(float y, float dt)
 {
     for (int i=scrollOffsets->num - 1; i >= 0; i--) {
         CCParallaxScrollOffset *scrollOffset = (CCParallaxScrollOffset*)scrollOffsets->arr[i];
         CCNode *child = scrollOffset->getChild();
         float offset = y * scrollOffset->getRatio().y;//ccpCompMult(pos, scrollOffset.ratio);
         child->setPosition(ccp(child->getPosition().x, scrollOffset->getOrigPosition().y + offset));
     }
 }
コード例 #5
0
void CCounter::animation(int digit)
{
    CCNode* presenter = _presenters->getChildByTag(digit);
    CCPoint dest = presenter->getPosition();
   // this->stopActionByTag(k_Counter_Action);
	_presenters->stopAllActions();
    CCMoveTo* moveTo = CCMoveTo::create(0.5, CCPointMake(0, -dest.y));
    _presenters->runAction(moveTo);
}
コード例 #6
0
ファイル: CCGameScrollView.cpp プロジェクト: 9cat/dotawar
bool CCCGameScrollView::ccTouchBegan( CCTouch *pTouch, CCEvent *pEvent )
{
    CCPoint touchPoint=pTouch->getLocation();
    
    //    将世界坐标转换为当前父View的本地坐标系
    
    CCPoint reallyPoint=this->getParent()->convertToNodeSpace(touchPoint);
    //CCPoint touchPoint = this->convertTouchToNodeSpace(pTouch);
    if (!this->boundingBox().containsPoint(reallyPoint)) {
        return false;
    }
    
	m_BeginOffset = getContentOffset();
    CCPoint m_EndOffset = getContentOffset();
    
	//点击Page的功能
//	if (m_BeginOffset.equals(m_EndOffset))
	{
		int nPage = -1;
		if (m_eDirection == kCCScrollViewDirectionHorizontal)
		{
			nPage = abs(m_EndOffset.x / (int)m_CellSize.width);
		}
		else
		{
			nPage = abs(m_EndOffset.y / (int)m_CellSize.height);
		}
		CCCGameScrollViewDelegate *pDele = (CCCGameScrollViewDelegate *)m_pDelegate;
		CCNode *pPgae = m_pContainer->getChildByTag(nPage);
		CCRect rcContent;
		rcContent.origin = pPgae->getPosition();
        
		rcContent.size = pPgae->getContentSize();
        //		rcContent.origin.x -= rcContent.size.width / 2;
        //	rcContent.origin.y -= rcContent.size.height / 2;
        CCPoint pos1 = this->convertTouchToNodeSpace(pTouch);
		CCPoint pos =pos1;
		if (m_eDirection == kCCScrollViewDirectionHorizontal)
		{
			pos.x += nPage * m_CellSize.width;
		}
		else
		{
			pos.y -= nPage * m_CellSize.height;
		}
        
		if (rcContent.containsPoint(pos))
		{
            pDele->scrollViewTouchBegan(pPgae,pos1);
            
		}
	
	}
    return  CCScrollView::ccTouchBegan(pTouch, pEvent);;
}
コード例 #7
0
KDvoid Ch1_1DEasingActions::step ( KDfloat fDelta )
{
	CCNode*		pBreadcrumbs = this->getChildByTag ( TAG_BREADCRUMBS );
	CCNode*		pNode = this->getChildByTag ( TAG_SPRITE_TO_MOVE );
	
	CCSprite*	pCrumb = CCSprite::create ( "blank.png" );
	pCrumb->setTextureRect ( CCRect ( 0, 0, 2, 2 ) );
	pCrumb->setColor ( ccc3 ( 255, 255, 0 ) );
	pCrumb->setPosition ( pNode->getPosition ( ) );
	pBreadcrumbs->addChild ( pCrumb );
}
コード例 #8
0
ファイル: ClippingNodeTest.cpp プロジェクト: 1901/cocos2d-x
void ScrollViewDemo::ccTouchesMoved(CCSet *pTouches, CCEvent *pEvent)
{
    if (!m_bScrolling) return;
	CCTouch *touch = (CCTouch*)pTouches->anyObject();
    CCNode *clipper = this->getChildByTag(kTagClipperNode);
    CCPoint point = clipper->convertToNodeSpace(CCDirector::sharedDirector()->convertToGL(touch->getLocationInView()));
	CCPoint diff = ccpSub(point, m_lastPoint);
    CCNode *content = clipper->getChildByTag(kTagContentNode);
    content->setPosition( ccpAdd(content->getPosition(), diff) );
    m_lastPoint = point;
}
コード例 #9
0
void CCounter::setDigit(int digit,bool bAnimate)
{
    if(_digit != digit){
        _digit = digit;
		CCNode* presenter = _presenters->getChildByTag(digit);
		CCPoint dest = presenter->getPosition();
		if(bAnimate)
			animation(digit);
		else
			_moveTo(digit,ccp(0, -dest.y));
    }
}
コード例 #10
0
ファイル: MainLayer.cpp プロジェクト: beforeeight/bump
void MainLayer::update(float delta)
{
	if (!disappearing)
	{
		CCNode *left = this->getChildByTag(TAG_LEFT);
		CCNode *right = this->getChildByTag(TAG_RIGHT);
		if (left && right)
		{

			CCRect leftRect = left->boundingBox();
			CCRect rightRect = right->boundingBox();
			leftRect.size = leftRect.size * 0.85f;
			rightRect.size = rightRect.size * 0.8f;
			if (leftRect.intersectsRect(rightRect))
			{
				disappearing = true;
				/*爆炸*/
				playDropAnimation();
			}
			else if (left->getPosition().x > right->getPosition().x)
			{
				disappearing = true;
				leftJumping = false;
				rightJumping = false;
				//计分
				Counter *counter = Counter::sharedCounter();
				(*counter)++;
				this->reCreateNewRole();
//			left->runAction(CCFadeOut::create(0.8f));
//			right->runAction(
//					CCSequence::createWithTwoActions(CCFadeOut::create(0.8f),
//							CCCallFunc::create(this,
//									callfunc_selector(
//											MainLayer::reCreateNewRole))));
			}
		}
	}

}
コード例 #11
0
ファイル: CCGameScrollView.cpp プロジェクト: 9cat/dotawar
void CCCGameScrollView::ccTouchEnded( CCTouch *pTouch, CCEvent *pEvent )
{
	CCPoint touchPoint = this->convertTouchToNodeSpace(pTouch);

	CCScrollView::ccTouchEnded(pTouch, pEvent);

	CCPoint m_EndOffset = getContentOffset();

	//点击Page的功能
	if (m_BeginOffset.equals(m_EndOffset))
	{
		int nPage = -1;
		if (m_eDirection == kCCScrollViewDirectionHorizontal)
		{
			nPage = abs(m_EndOffset.x / (int)m_CellSize.width);
		}
		else
		{
			nPage = abs(m_EndOffset.y / (int)m_CellSize.height);
		}
		CCCGameScrollViewDelegate *pDele = (CCCGameScrollViewDelegate *)m_pDelegate;
		CCNode *pPgae = m_pContainer->getChildByTag(nPage);
		CCRect rcContent;
		rcContent.origin = pPgae->getPosition();
      
		rcContent.size = pPgae->getContentSize();
//		rcContent.origin.x -= rcContent.size.width / 2;
//	rcContent.origin.y -= rcContent.size.height / 2;

		CCPoint pos = touchPoint;
		if (m_eDirection == kCCScrollViewDirectionHorizontal)
		{
			pos.x += nPage * m_CellSize.width;
		}
		else
		{
			pos.y -= nPage * m_CellSize.height;
		}

		if (rcContent.containsPoint(pos))
		{
			pDele->scrollViewClick(m_EndOffset, touchPoint, pPgae, nPage);
            pDele->scrollViewTouchEnded(this,touchPoint);
            
		}
		return ;
	}

	//自动调整
	adjustScrollView(m_BeginOffset, m_EndOffset);
}
コード例 #12
0
ファイル: Box2dView.cpp プロジェクト: YarinYang/cocos2dx-win8
void MenuLayer::ccTouchMoved(CCTouch* touch, CCEvent* event)
{
	CCPoint touchLocation = touch->locationInView( touch->view() );	
	CCPoint prevLocation = touch->previousLocationInView( touch->view() );	
	
	touchLocation = CCDirector::sharedDirector()->convertToGL( touchLocation );
	prevLocation = CCDirector::sharedDirector()->convertToGL( prevLocation );
	
	CCPoint diff = ccpSub(touchLocation,prevLocation);
	
	CCNode *node = getChildByTag( kTagBox2DNode );
	CCPoint currentPos = node->getPosition();
	node->setPosition( ccpAdd(currentPos, diff) );
}
コード例 #13
0
void GUISpinView::update(float delta)
{
    CCArray * array = m_mainNode->getChildren();
    if (array) {
        for (int i = 0; i < array->count(); i++) {
            CCNode * node = (CCNode *)array->objectAtIndex(i);
            CCPoint p = node->getPosition();
            if (p.y + m_itemHeight * 0.5f < - m_viewFrame.size.height * 0.5f) {
                p.y += m_itemCount * m_itemHeight;
                node->setPosition(p);
            }
        }
    }
}
コード例 #14
0
void MainMenu::update(float dt)
{
	CCLayer::update(dt);
	CCPoint bgVel = ccp(-1000,0);
	bgSpace->setPosition( ccpAdd(bgSpace->getPosition(), ccpMult(bgVel,dt)) );
	CCArray* bgs = CCArray::create(stars1,stars2,NULL);
	CCObject* obj = NULL;
	CCARRAY_FOREACH(bgs,obj)
	{
		CCNode* node = (CCNode*)obj;
		if(bgSpace->convertToWorldSpace(node->getPosition()).x < -node->getContentSize().width/2)
		{
			bgSpace->incrementOffset(ccp(2*node->getContentSize().width,0),node);
		}
	}
コード例 #15
0
void ParallaxBackground::Scroll(CCTouch* touch)
{
    CCPoint diff = touch->getDelta();

    CCNode* node = getChildByTag(0);
    CCPoint currentPos = node->getPosition();
    float xpos = currentPos.x + diff.x;
    float ypos = currentPos.y/* + diff.y*/;

    ypos = std::max(ypos, -35.f);
    ypos = std::min(ypos, 35.f);

    xpos = std::max(xpos, -50.f);
    xpos = std::min(xpos, 50.f);

    node->setPosition(xpos , ypos );
}
コード例 #16
0
void CCMissile::step(float dt) {
    // position of target and aimed
    CCNode* target = getTarget();
    CCPoint t = target->getPosition();
    CCPoint a = m_aimed->getPosition();
    
    // position vector degree
    CCPoint v = ccpSub(a, t);
    float r = ccpToAngle(v);
    float d = -CC_RADIANS_TO_DEGREES(r);
    d -= m_presetDegree;
    
    // save dest degree
    if(m_dstDegree != d) {
        m_dstDegree = d;
    }
    
    // rotate to dst degree gradually
    if(m_dstDegree > target->getRotation()) {
        float cur = MIN(m_dstDegree, target->getRotation() + dt * ANGULAR_VELOCITY);
        target->setRotation(cur);
    } else if(m_dstDegree < target->getRotation()) {
        float cur = MAX(m_dstDegree, target->getRotation() - dt * ANGULAR_VELOCITY);
        target->setRotation(cur);
    }
    
    // move target by velocity
    float move = m_velocity * dt;
    float distance = ccpLength(v);
    if(move >= distance) {
        target->setPosition(a);
    } else {
        t.x += move * cosf(r);
        t.y += move * sinf(r);
        target->setPosition(t);
    }
	
	// is done?
	m_done = getTarget()->getPositionX() == m_aimed->getPositionX() &&
		getTarget()->getPositionY() == m_aimed->getPositionY();
	
	// done callback
	if(m_done && m_doneCallFunc) {
		m_doneCallFunc->execute();
	}
}
コード例 #17
0
ファイル: LoginView.cpp プロジェクト: fengmm521/qipaiproject
/**
*   键盘将要出现的时候
*/
void LoginView::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
    CCLog("LoginView:keyboardWillShowAt(origin:%f,%f, size:%f,%f)",
        info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height);

    if (! this->mTrackNodeArray)
    {
        return;
    }

    CCNode* trackNode = NULL ;
    CCRect rectTracked ;
    for(int i=0; i<this->mTrackNodeArray->count(); i++) 
    {
        trackNode = (CCNode*) this->mTrackNodeArray->objectAtIndex(i) ;

        rectTracked = getRect(trackNode);
        CCLog("LoginView:trackingNodeAt(origin:%f,%f, size:%f,%f)",
            rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height);

        // if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
        if (! CCRect::CCRectIntersectsRect(rectTracked, info.end))
        {
            continue ;
        }

        // assume keyboard at the bottom of screen, calculate the vertical adjustment.
        float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
        CCLog("LoginView:needAdjustVerticalPosition(%f)", adjustVert);

        // move all the children node of KeyboardNotificationLayer
        CCArray* children = getChildren();
        CCNode* node = 0;
        int count = children->count();
        CCPoint pos;
        for (int i = 0; i < count; ++i)
        {
            node = (CCNode*)children->objectAtIndex(i);
            pos = node->getPosition();
            pos.y += adjustVert;
            node->setPosition(pos);
        }
    }

    
}
コード例 #18
0
ファイル: CGameMenu.cpp プロジェクト: JoeHu/magicpet
//---------------------------------------------------------------
//
//
void CAbout::onEnter()
{
	CCXMLLayer::onEnter();
	LoadPlist("about.plist");

	CCNode *pNode = GetXMLNodeFromKey( "t2dSceneObject_Message" );

	string utf8;
	CChineseCode::GB2312ToUTF_8( utf8, (char*)the_loginmain_designer_text[g_iCurLanguageIndex], 512 );

	CCLabelTTF* pLabel = CCLabelTTF::labelWithString( utf8.c_str(),CCSize( 0,0 ), CCTextAlignmentLeft, kFontSystem[FONT_THIN].fontName, kFontSystem[FONT_THIN].fontSize );
	pLabel->setPosition( pNode->getPosition() );
	CCRenderTexture* pstroke = createStroke(pLabel, 1, kFontSystem[FONT_THIN].strokeColor);
	addChild( pstroke,100 );
	addChild( pLabel,100 );

	setIsTouchEnabled( true );

}
コード例 #19
0
void LCCrossMatchGame::shuffleNodes(CCArray* nodeArray)
{
	CCArray *tempArray = CCArray::arrayWithArray(nodeArray);
	CCPoint *tempPosition = (CCPoint *)malloc(sizeof(CCPoint) * nodeArray->count());
	
	for (int i=0; i<nodeArray->count(); i++) {
		CCNode* node = (CCNode*)tempArray->randomObject();
		tempArray->removeObject(node);
		
		tempPosition[i] = node->getPosition();
	}
	
	for (int i=0; i<nodeArray->count(); i++) {
		CCNode* node = (CCNode*)nodeArray->objectAtIndex(i);
		node->setPosition(tempPosition[i]);
	}
	
	free(tempPosition);
}
コード例 #20
0
void CCCardinalSplineTo::update(float time)
{
    unsigned int p;
    float lt;
	
	// eg.
	// p..p..p..p..p..p..p
	// 1..2..3..4..5..6..7
	// want p to be 1, 2, 3, 4, 5, 6
    if (time == 1)
    {
        p = m_pPoints->count() - 1;
        lt = 1;
    }
    else 
    {
        p = time / m_fDeltaT;
        lt = (time - m_fDeltaT * (float)p) / m_fDeltaT;
    }
    
	// Interpolate    
    CCPoint pp0 = m_pPoints->getControlPointAtIndex(p-1);
    CCPoint pp1 = m_pPoints->getControlPointAtIndex(p+0);
    CCPoint pp2 = m_pPoints->getControlPointAtIndex(p+1);
    CCPoint pp3 = m_pPoints->getControlPointAtIndex(p+2);
	
    CCPoint newPos = ccCardinalSplineAt(pp0, pp1, pp2, pp3, m_fTension, lt);
	
#if CC_ENABLE_STACKABLE_ACTIONS
    // Support for stacked actions
    CCNode *node = m_pTarget;
    CCPoint diff = ccpSub( node->getPosition(), m_previousPosition);
    if( diff.x !=0 || diff.y != 0 ) {
        m_accumulatedDiff = ccpAdd( m_accumulatedDiff, diff);
        newPos = ccpAdd( newPos, m_accumulatedDiff);
    }
#endif
    
    this->updatePosition(newPos);
}
コード例 #21
0
ファイル: CCMenuItem.cpp プロジェクト: saranpol/cocos2d-x
void CCMenuItem::selected()
{
    m_bSelected = true;
    // #HLP_BEGIN
    
    CCNode *p;
    if(mIsMoveDownWhenSelected || mFadeAnim)
        p = getParent2();

    if(mIsMoveDownWhenSelected){
        CCPoint pos = p->getPosition();
        if(!mIsParentOriginalPosSet){
            mParentOriginalPos = pos;
            mIsParentOriginalPosSet = true;
        }
        pos.y = pos.y - 2.0f;
        CCFiniteTimeAction *move = CCMoveTo::create(0.3f, pos);
        p->stopAllActions();
        move = CCEaseExponentialOut::create((CCActionInterval*)move);
        p->runAction(CCSequence::create(move, NULL));
        
        CCFiniteTimeAction *tint = CCTintTo::create(0.3f, mSelectTint.r, mSelectTint.g, mSelectTint.b);
        tint = CCEaseExponentialOut::create((CCActionInterval*)tint);
        p->runAction(CCSequence::create(tint, NULL));
        
    }

    if(mFadeAnim){
        CCNode *n = p->getChildByTag(LAYER_FADE_TAG);
        if(n){
            CCFiniteTimeAction *fade = CCFadeTo::create(0.5f, 80);
            fade = CCEaseExponentialOut::create((CCActionInterval*)fade);
            n->runAction(CCSequence::create(fade, NULL));
        }
    }

    // #HLP_END
}
コード例 #22
0
//---------------------------------------------------------
//
//
void CMessageBoxYesNo::onEnter()
{
    CCXMLLayer::onEnter();
    
    LoadPlist( "tip_1.plist" );
    
    const char *MenuButton[] = { "button_yes", "button_no" };
    
    const char *YesNo[] = { "YES", "NO" };
    for( int i = 0; i < 2; i++ )
	{
		CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( MenuButton[i] );
		CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(CMessageBoxYesNo::menuCallback), i, this, pSprite->getPosition() );
		addChild( pMenu, pSprite->getZOrder() );
        removeChild( pSprite, true );
        
        
        CCLabelTTF* pLabelTTF = CCLabelTTF::labelWithString( YesNo[i], kFontSystem[FONT_GRAND].fontName, kFontSystem[FONT_GRAND].fontSize );
        pLabelTTF->setPosition( pMenu->getPosition() );
        CCRenderTexture* pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_GRAND].strokeColor);
        addChild( pstroke,100 );
        addChild( pLabelTTF,100 );
	}
    
    CCNode *pNode =  GetXMLNodeFromKey( "t2dSceneObject_Message" );
	CCLabelTTF* pLabelTTF = CCLabelTTF::labelWithString( m_szBuffer, kFontSystem[FONT_THIN].fontName, kFontSystem[FONT_THIN].fontSize );
	pLabelTTF->setPosition( pNode->getPosition() );
    CCRenderTexture* pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_THIN].strokeColor);
    addChild( pstroke,100 );
	addChild( pLabelTTF,100 );
    
    //pNode =  GetXMLNodeFromKey( "t2dSceneObject_tipname" );
	//pLabelTTF = CCLabelTTF::labelWithString( m_TitleBuffer, kFontSystem[FONT_THIN].fontName, kFontSystem[FONT_THIN].fontSize );
	//pLabelTTF->setPosition( pNode->getPosition() );
    //pstroke = createStroke(pLabelTTF, 1, kFontSystem[FONT_THIN].strokeColor);
    //addChild( pstroke,100 );
	//addChild( pLabelTTF,100 );
}
コード例 #23
0
void KeyboardNotificationLayer::keyboardWillShow(CCIMEKeyboardNotificationInfo& info)
{
    CCLOG("TextInputTest:keyboardWillShowAt(origin:%f,%f, size:%f,%f)",
        info.end.origin.x, info.end.origin.y, info.end.size.width, info.end.size.height);

    if (! m_pTrackNode)
    {
        return;
    }

    CCRect rectTracked = getRect(m_pTrackNode);
    CCLOG("TextInputTest:trackingNodeAt(origin:%f,%f, size:%f,%f)",
        rectTracked.origin.x, rectTracked.origin.y, rectTracked.size.width, rectTracked.size.height);

    // if the keyboard area doesn't intersect with the tracking node area, nothing need to do.
    if (! rectTracked.intersectsRect(info.end))
    {
        return;
    }

    // assume keyboard at the bottom of screen, calculate the vertical adjustment.
    float adjustVert = info.end.getMaxY() - rectTracked.getMinY();
    CCLOG("TextInputTest:needAdjustVerticalPosition(%f)", adjustVert);

    // move all the children node of KeyboardNotificationLayer
    CCArray * children = getChildren();
    CCNode * node = 0;
    int count = children->count();
    CCPoint pos;
    for (int i = 0; i < count; ++i)
    {
        node = (CCNode*)children->objectAtIScutex(i);
        pos = node->getPosition();
        pos.y += adjustVert;
        node->setPosition(pos);
    }
}
コード例 #24
0
ファイル: RootLayer.cpp プロジェクト: hyizsg/mytest1st
void HRootLayer::adjustPostionAndScale(CCNode* node, float scaleX, float scaleY) {
    
    for (int i = 0; i < m_pIgnoreNodeArr->count(); i ++) {
        CCNode* node = dynamic_cast<CCNode*>(m_pIgnoreNodeArr->objectAtIndex(i));
        if (node) {
            node->setScaleX(scaleX);
            node->setScaleY(scaleY);
        }
    }
    
    CCArray *children = node->getChildren();
    if (children) {
        for (int i = children->count() - 1; i >= 0; --i) {
            CCNode *child = (CCNode *)children->objectAtIndex(i);
            if (!m_pIgnoreNodeArr->containsObject(child)) {
                
                CCPoint pos = child->getPosition();
                child->setPosition(ccp(pos.x * scaleX, pos.y * scaleY));
                
            }
        }
    }

}
コード例 #25
0
ファイル: CameraObserver.cpp プロジェクト: boyjimeking/Demo
    void CameraObserver::OnNotifyChange(INotifier *notify, const INotifyEvent *event)
    {
        if (NULL == event)
        {
            return;
        }
        switch (event->GetNotifyEventType())
        {
            case ENCameraEvent::enPosChanged:
                {
                    const CameraPosChanged *posChangedEvent = reinterpret_cast<const CameraPosChanged*>(event);
                    //setPosition(cocos2d::ccpNeg(posChangedEvent->GetCameraPosition()));
					cocos2d::CCPoint newPos = cocos2d::ccpNeg(posChangedEvent->GetCameraPosition());
					cocos2d::CCPoint dis = cocos2d::ccpSub(newPos, m_lastPos);
					if ( m_pChildren && m_pChildren->count() > 0 )
					{
						CCObject* child;
						CCARRAY_FOREACH(m_pChildren, child)
						{
							CCNode* pNode = (CCNode*)child;
							if (pNode)
							{
								MoveScale::iterator it = m_moveScale.find(pNode);
								if (m_moveScale.end() == it)
								{
									pNode->setPosition(newPos);
								}
								else
								{
									pNode->setPosition(ccpAdd(pNode->getPosition(), ccpMult(dis, it->second)));
								}
							}
						}
					}
					m_lastPos = cocos2d::ccpNeg(posChangedEvent->GetCameraPosition());
                }
コード例 #26
0
//---------------------------------------------------------
//
//
void CMiniGameGamblingLayer::onEnter()
{
    CNd91Mng::RemoveBanner();
    CNd91Mng::InitadBanner();
    
	CCXMLLayer::onEnter();
    
    LoadPlist( "minigame3_gambling.plist");

	CCSprite *pSprite= (CCSprite*)GetXMLNodeFromKey( "button_back" );
    CCMenu *pMenu = CreatGameUIWithSprite( pSprite, menu_selector(CMiniGameGamblingLayer::menuCallback), 0, this, pSprite->getPosition() );
    addChild( pMenu, pSprite->getZOrder());
    removeChild( pSprite, true );

	pSprite= (CCSprite*)GetXMLNodeFromKey( "pushrod" );
	
	m_pPushBar = pSprite;

	m_pPushBar->setAnchorPoint( ccp( 0.5f,0.0f ) );

	m_pPushBar->setPosition( ccp( m_pPushBar->getPosition().x, m_pPushBar->getPosition().y - m_pPushBar->getTextureRect().size.height / 2 ) );


	m_pFood[0] = (AdvanceSprite*)GetXMLNodeFromKey( "t2dAnimatedSprite_food_1" );

	m_pFood[1] = (AdvanceSprite*)GetXMLNodeFromKey( "t2dAnimatedSprite_food_2" );

	m_pFood[2] = (AdvanceSprite*)GetXMLNodeFromKey( "t2dAnimatedSprite_food_3" );

	CCNode *pNode = GetXMLNodeFromKey( "t2dSceneObject_money" );
    m_plabelMoney = CCLabelTTF::labelWithString("0",  kFontSystem[FONT_GRAND].fontName,kFontSystem[FONT_GRAND].fontSize);
	m_plabelMoney->setPosition(pNode->getPosition());
	m_plabelMoney->setColor( ccBlack );
	addChild(m_plabelMoney,100);

	pNode = GetXMLNodeFromKey( "t2dSceneObject_winmoney" );
	m_plabelWinMoney = CCLabelTTF::labelWithString("0",  kFontSystem[FONT_SMALL].fontName,kFontSystem[FONT_SMALL].fontSize);
	m_plabelWinMoney->setPosition(pNode->getPosition());
	m_plabelWinMoney->setColor( ccBlack );
	addChild(m_plabelWinMoney,100);

	pNode = GetXMLNodeFromKey( "t2dSceneObject_lostmoney" );
	m_plabelLostMoney = CCLabelTTF::labelWithString("200",  kFontSystem[FONT_SMALL].fontName,kFontSystem[FONT_SMALL].fontSize);
	m_plabelLostMoney->setPosition(pNode->getPosition());
	m_plabelLostMoney->setColor( ccBlack );
	addChild(m_plabelLostMoney,100);

	schedule( schedule_selector( CMiniGameGamblingLayer::UpData ), 0.1f );


	CCSize size = CCDirector::sharedDirector()->getWinSize();


	string path = GetGameImagesPath();
	path = path + "lose.png";
	m_pSpriteLost = CCSprite::spriteWithFile( path.c_str() );
	addChild( m_pSpriteLost, 100 );
	m_pSpriteLost->setPosition( ccp( size.width/2, size.height/2 ) );
	m_pSpriteLost->setIsVisible( false );

	path = GetGameImagesPath();
	path = path + "win.png";
	m_pSpriteWin = CCSprite::spriteWithFile( path.c_str() );
	addChild( m_pSpriteWin, 100 );
	m_pSpriteWin->setPosition( ccp( size.width/2, size.height/2 ) );
	m_pSpriteWin->setIsVisible( false );

}
コード例 #27
0
ファイル: HelloWorldScene.cpp プロジェクト: amy60618/android
void HelloWorld::tick(float dt) {
	int velocityIterations = 8;
	int positionIterations = 1;
	
	m_world->Step(dt, velocityIterations, positionIterations);
	for (b2Body* b = m_world->GetBodyList(); b; b = b->GetNext()) {
		if (b->GetUserData() != NULL) {
			CCSprite* sprite = (CCSprite*)(b->GetUserData());
			sprite->setPosition(ccp(b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO));
			sprite->setRotation( -1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
			
		}
	}
	if (m_releasingArm && m_bulletJoint != NULL) {
		if (m_armJoint->GetJointAngle() <= CC_DEGREES_TO_RADIANS(10)) {
			m_releasingArm = false;
			m_world->DestroyJoint(m_bulletJoint);
			m_bulletJoint = NULL;

			CCDelayTime* delayAction = CCDelayTime::create(5.0f);
			CCCallFunc* callSelectorAction = CCCallFunc::create(this, callfunc_selector(HelloWorld::resetBullet));
			this->runAction(CCSequence::create(delayAction, callSelectorAction, NULL));
		}
	}
	if (m_bulletBody && m_bulletJoint == NULL) {
		b2Vec2 position = m_bulletBody->GetPosition();
		CCPoint myPosition = this->getPosition();
		CCSize screenSize = CCDirector::sharedDirector()->getWinSize();
		if (position.x > screenSize.width/2.0f/PTM_RATIO) {
			myPosition.x = -MIN(screenSize.width*2.0f - screenSize.width,
				position.x*PTM_RATIO - screenSize.width/2.0f);
			this->setPosition(myPosition);
		}
	}
    std::set<b2Body*>::iterator pos;
	for (pos = contactListener->contacts.begin(); pos != contactListener->contacts.end(); ++pos) {
		b2Body* body = *pos;
		for (vector<b2Body*>::iterator iter = targets->begin(); iter != targets->end(); ++iter) {
			if (body == *iter) {
				iter = targets->erase(iter);
				break;
			}
		}
		for (vector<b2Body*>::iterator iter = enemies->begin(); iter != enemies->end(); ++iter) {
			if (body == *iter) {
				iter = enemies->erase(iter);
				break;
			}
		}
		CCNode* contactNode = (CCNode*)body->GetUserData();
		CCPoint position = contactNode->getPosition();
		removeChild(contactNode, true);
		m_world->DestroyBody(body);

		CCParticleSun *explosion = CCParticleSun::create();
		explosion->retain();
		explosion->setTexture(CCTextureCache::sharedTextureCache()->addImage("fire.png"));
//		explosion->initWithTotalParticles(200);
		explosion->setAutoRemoveOnFinish(true);
		explosion->setStartSizeVar(10.0f);
		explosion->setSpeed(70.0f);
		explosion->setAnchorPoint(ccp(0.5f, 0.5f));
		explosion->setPosition(position);
		explosion->setDuration(1.0f);
		addChild(explosion, 11);
		explosion->release();
	}
	contactListener->contacts.clear();
}
コード例 #28
0
void CCINode::showFrame(){
    //std::vector<CCIMovieTag *> tags = this->swfMovie->getTags();

    while (true) {
        CCIMovieTag * tag = NULL;
        
        if (currentTag<tags.size()) {
            tag = tags[currentTag++];
        }else{
            
            this->removeAllChildrenWithCleanup(true);
            //this->stop();
            currentTag = 0;
            currentFrame = 0;
            break;
        }
        if(tag->getTagType()==TagTypePlaceObject||tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3){
            CCIPlaceObject * placeTag = (CCIPlaceObject *)tag;
            
            int charactorId = placeTag->getCharacterId();
            int depth = placeTag->getDepth();
            
            
            CCIPlaceObject2 * placeTag2 = NULL;
            if (tag->getTagType()==TagTypePlaceObject2||tag->getTagType()==TagTypePlaceObject3) {
                placeTag2 = (CCIPlaceObject2 *)tag;
            }
            
            CCNode * node;
            if (!placeTag2||placeTag2->placeType==PlaceObjectTypeNew) {
                //place1 or placetag2 new
                node = (CCNode *)this->nodes->objectForKey(charactorId);
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeModify){
                node = (CCNode *)this->getChildByTag(depth);
            }else if(placeTag2&&placeTag2->placeType==PlaceObjectTypeReplace){
                
                CCNode * newNode = (CCNode *)this->nodes->objectForKey(charactorId);
                
                node = (CCNode *)this->getChildByTag(depth);
                if (node) {
                    if (newNode) {
                        //get last transform matrix
                        newNode->setPosition(node->getPosition());
                        newNode->setScaleX(node->getScaleX());
                        newNode->setScaleY(node->getScaleY());
                        newNode->setSkewX(node->getSkewX());
                        newNode->setSkewY(node->getSkewY());
                    }
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->stop();
                    }
                    node->removeFromParentAndCleanup(true);
                }
                
                node = newNode;
                if (node&&node->getParent()==NULL) {
                    this->addChild(node, depth, depth);
                    CCInteger * nodeType = (CCInteger *)node->getUserObject();
                    if (nodeType->getValue()==NodeTypeCCINode) {
                        CCINode * ccinode = (CCINode *)node;
                        ccinode->play();
                    }
                }
                
            }
            
            if (node) {
                CCIMatrix * matrix = placeTag->getMatrix();
                if (matrix) {
                    int x = matrix->getTranslateX();
                    int y = matrix->getTranslateY();
                    
                    node->setPosition(this->swfMovie->getHeader()->getBounds()->convertToCCSpace(x, y));
                    //restore
                    float scaleX = 1.0;
                    float scaleY = 1.0;
                    node->setScaleX(1);
                    node->setScaleY(1);
                    node->setSkewX(0);
                    node->setSkewY(0);
                    
                    if (matrix->HasScale) {
                        scaleX = matrix->getScaleX();
                        scaleY = matrix->getScaleY();
                        node->setScaleX(scaleX);
                        node->setScaleY(scaleY);
                    }
                    if (matrix->HasRotate) {
                        float skewX = matrix->getSkewX();
                        float skewY = matrix->getSkewY();
                        
                        this->applySkew(node, skewX, skewY,false);
                    }
                    
                }
                CCICxform * colorTransform = placeTag->getColorTransform();
                
                int red = 255;
                int green = 255;
                int blue = 255;
                int alpha = 255;
                
                if (colorTransform) {
                    if (colorTransform->HasMultTerms) {
                        red = colorTransform->RedMultTerm-1;
                        green = colorTransform->GreenMultTerm-1;
                        blue = colorTransform->BlueMultTerm-1;
                        if (colorTransform->hasAlpha()) {
                            CCICxformWithAlpha * cxformAlpha = (CCICxformWithAlpha *)colorTransform;
                            alpha = cxformAlpha->AlphaMultTerm-1;
                        }
                    }
                    
                    if (colorTransform->HasAddTerms) {
                        //TODO no add term
                    }
                    if (red==-1) {
                        red = 0;
                    }
                    if (green ==-1) {
                        green = 0;
                    }
                    if (blue == -1) {
                        blue = 0;
                    }
                    if (alpha ==-1) {
                        alpha = 0;
                    }
                }
                
                this->applyColorTransform(node, ccc4(red, green, blue, alpha));
                
                if (tag->getTagType()==TagTypePlaceObject3) {
                    //check filters
                    CCIPlaceObject3 * placeTag3 = (CCIPlaceObject3 *)tag;
                    
                    CCIFilterList * filterList = placeTag3->getFilterList();
                        
                    if (filterList) {
                        //apply filter list
                        for (int i=0; i<filterList->NumberOfFilters; i++) {
                            //CCIFilter * filter = filterList->Filter[i];
                            
                        }
                    }
                }
            }
        }else if (tag->getTagType()==TagTypeRemoveObject||tag->getTagType()==TagTypeRemoveObject2){
            CCIRemoveObject * removeTag = (CCIRemoveObject *)tag;
            int depth = removeTag->getDepth();
            CCNode * node = this->getChildByTag(depth);
            if (node) {
                CCInteger * nodeType = (CCInteger *)node->getUserObject();
                if (nodeType->getValue()==NodeTypeCCINode) {
                    CCINode * ccinode = (CCINode *)node;
                    ccinode->stop();
                }
                node->removeFromParentAndCleanup(true);
            }
        }else if(tag->getTagType()==TagTypeFrameLabel){
            if (isPlayingFrameLabel&&currentTag!=frameLabelIndex) {
                currentTag = frameLabelIndex;
                currentFrame = 0;
                //this->removeAllChildrenWithCleanup(true);
                break;
            }
        }else if(tag->getTagType()==TagTypeShowFrame){
            if (this->delegate) {
                this->delegate->didEnterFrame(currentFrame, this->frameLabel);
            }
            currentFrame++;
            
            break;
        }
    }
}
コード例 #29
0
ファイル: MenuTest.cpp プロジェクト: charlesa101/cocos2d-x
//------------------------------------------------------------------
//
// MenuLayer1
//
//------------------------------------------------------------------
MenuLayer1::MenuLayer1()
{
	CCMenuItemFont::setFontSize( 30 );
	CCMenuItemFont::setFontName("Courier New");

	// Font Item
	
	CCSprite* spriteNormal = CCSprite::spriteWithFile(s_MenuItem, CGRectMake(0,23*2,115,23));
	CCSprite* spriteSelected = CCSprite::spriteWithFile(s_MenuItem, CGRectMake(0,23*1,115,23));
	CCSprite* spriteDisabled = CCSprite::spriteWithFile(s_MenuItem, CGRectMake(0,23*0,115,23));
	//dynamic_cast<CCNode*>(mgr)->addChild(spriteNormal);
	//dynamic_cast<CCNode*>(mgr)->addChild(spriteSelected);
	//dynamic_cast<CCNode*>(mgr)->addChild(spriteDisabled);

	CCMenuItemSprite* item1 = CCMenuItemSprite::itemFromNormalSprite(spriteNormal, spriteSelected, spriteDisabled, this, menu_selector(MenuLayer1::menuCallback) );
	
	// Image Item
	CCMenuItem* item2 = CCMenuItemImage::itemFromNormalImage(s_SendScore, s_PressSendScore, this, menu_selector(MenuLayer1::menuCallback2) );

	// Label Item (LabelAtlas)
	CCLabelAtlas* labelAtlas = CCLabelAtlas::labelAtlasWithString("0123456789", "fonts/fps_images.png", 16, 24, '.');
	CCMenuItemLabel* item3 = CCMenuItemLabel::itemWithLabel(labelAtlas, this, menu_selector(MenuLayer1::menuCallbackDisabled) );
	item3->setDisabledColor( ccc3(32,32,64) );
	item3->setColor( ccc3(200,200,255) );
	
	// Font Item
	CCMenuItem *item4 = CCMenuItemFont::itemFromString("I toggle enable items", this, menu_selector(MenuLayer1::menuCallbackEnable) );
	
	// Label Item (BitmapFontAtlas)
	CCBitmapFontAtlas* label = CCBitmapFontAtlas::bitmapFontAtlasWithString("configuration", "fonts/bitmapFontTest3.fnt");
	CCMenuItemLabel* item5 = CCMenuItemLabel::itemWithLabel(label, this, menu_selector(MenuLayer1::menuCallbackConfig));

	// Testing issue #500
	item5->setScale( 0.8f );

	// Font Item
	CCMenuItemFont* item6 = CCMenuItemFont::itemFromString("Quit", this, menu_selector(MenuLayer1::onQuit));
	
	CCIntervalAction* color_action = CCTintBy::actionWithDuration(0.5f, 0, -255, -255);
	CCIntervalAction* color_back = color_action->reverse();
	CCFiniteTimeAction* seq = CCSequence::actions(color_action, color_back, NULL);
	item6->runAction(CCRepeatForever::actionWithAction((CCIntervalAction*)seq));

	CCMenu* menu = CCMenu::menuWithItems( item1, item2, item3, item4, item5, item6, NULL);
	menu->alignItemsVertically();
	
	
	// elastic effect
	CGSize s = CCDirector::sharedDirector()->getWinSize();
	
	int i=0;
	CCNode* child;
	NSMutableArray<CCNode*> * pArray = menu->getChildren();
    NSMutableArray<CCNode*>::NSMutableArrayIterator it;

	for(it = pArray->begin(); it != pArray->end(); it++)
	{
		if(*it == NULL)
			break;

		child = (CCNode*)(*it);

		CGPoint dstPoint = child->getPosition();
		int offset = (int) (s.width/2 + 50);
		if( i % 2 == 0)
			offset = -offset;
		
		child->setPosition( CGPointMake( dstPoint.x + offset, dstPoint.y) );
		child->runAction( 
							CCEaseElasticOut::actionWithAction(
																CCMoveBy::actionWithDuration(2, CGPointMake(dstPoint.x - offset,0)), 0.35f
															) 
						);
		i++;
	}

	m_disabledItem = item3; item3->retain();
	m_disabledItem->setIsEnabled( false );

	addChild(menu);

}
コード例 #30
0
void HelloWorld::tick(ccTime dt)
{
	int velocityIterations = 8;
	int positionIterations = 1;
	world->Step(dt, velocityIterations, positionIterations);
	for (b2Body* b = world->GetBodyList(); b; b=b->GetNext())
	{
		if(b->GetUserData() != NULL)
		{
			CCSprite *myActor = (CCSprite *)b->GetUserData();
			myActor->setPosition(ccp(b->GetPosition().x * PTM_RATIO, b->GetPosition().y * PTM_RATIO));
			myActor->setRotation(-1 * CC_RADIANS_TO_DEGREES(b->GetAngle()));
		}
	}

	//Arm is being released
	if (releasingArm && bulletJoint)
	{
		if(armJoint->GetJointAngle() <= CC_DEGREES_TO_RADIANS(10))
		{
			releasingArm = false;
			world->DestroyJoint(bulletJoint);
			bulletJoint = NULL;
			this->schedule(schedule_selector(HelloWorld::resetBullet), 5.0f);
		}
	}

	//Bullet is moving
	if (bulletBody != nullptr && bulletJoint == NULL)
	{
		b2Vec2 position = bulletBody->GetPosition();
		CCPoint myPosition = this->getPosition();
		CCSize screenSize = CCDirector::sharedDirector()->getWinSize();

		if(position.x > screenSize.width / 2.0f / PTM_RATIO)
		{
			myPosition.x = -MIN(960.0f - screenSize.width, position.x * PTM_RATIO - screenSize.width / 2.0f);
			this->setPosition(myPosition);
		}
	}

	set<b2Body*>::iterator pos;
	for(pos = contactListener->contacts.begin(); pos != contactListener->contacts.end(); ++pos)
	{
		b2Body *body = *pos;
		CCNode *contactNode = (CCNode *) body->GetUserData();
		CCPoint position = contactNode->getPosition();
		this->removeChild(contactNode,true);
		world->DestroyBody(body);
		for(vector<b2Body*>::size_type i = 0; i >= targets->size(); i++)
		{
			try
			{
				if(targets->at(i) == body)
				{
					if(i == targets->size()-1)
					{
						printf("asdf");
					}
					targets->erase(targets->begin() + i);
				}
			}
			catch(exception e)
			{
				enemies->clear();
				break;
			}
		}
		for(vector<b2Body*>::size_type i = 0; i >= enemies->size(); i++)
		{
			try
			{
				if(enemies->at(i) == body)
				{
					if(i == enemies->size()-1)
					{
						printf("asdf");
					}
					enemies->erase(enemies->begin() + i);
				}
			}
			catch(exception e)
			{
				enemies->clear();
				break;
			}
		}

		CCParticleSun* explosion = new CCParticleSun();
		explosion->initWithTotalParticles(200);
		//explosion->setTotalParticles(200);
		explosion->setAutoRemoveOnFinish(true);
		explosion->setStartSize(10.0f);
		explosion->setSpeed(70.0f);
		explosion->setAnchorPoint(ccp(0.5f,0.5f));
		explosion->setPosition(position);
		explosion->setDuration(1.0f);
		CCTexture2D *tex = new CCTexture2D();
		CCImage *img = new CCImage();
		img->initWithImageFile("fire.png");
		tex->initWithImage(img);
		explosion->setTexture(tex);
		this->addChild(explosion, 11);
		explosion->release();
	}

	contactListener->contacts.clear();
}