首页 > 其他 > 详细

哇!板球 源码分析三

时间:2014-06-02 05:03:36      阅读:454      评论:0      收藏:0      [点我收藏+]

守门员出场

bubuko.com,布布扣

守门员出场,每个守门员是从屏幕的右侧中间的位置随机方向向左侧移动

FielderSprite* fielderSprite1 = FielderSprite::create("pic/fielder.png");
	//守门员精灵初始位置为右侧中间位置
	fielderSprite1->setPosition(ccp(GOALKEEPER_X, GOALKEEPER_Y));
	fielderSprite1->setAnchorPoint(ccp(0.5, 0.5));//默认锚点为0.5,0.5
	//将fielder精灵添加到布景中
	this->addChild(fielderSprite1, GAME_LEVEL_WYF);


动作序列中的6个动作,终点都在最左侧

	CCActionInterval* at1=CCMoveBy::create(3.5,CCPointMake(-800,-170));
	CCActionInterval* at2=CCMoveBy::create(4,CCPointMake(-800,-100));
	CCActionInterval* at3=CCMoveBy::create(2.5,CCPointMake(-800,-30));
	CCActionInterval* at4=CCMoveBy::create(4.5,CCPointMake(-800,40));
	CCActionInterval* at5=CCMoveBy::create(5,CCPointMake(-800,110));
	CCActionInterval* at6=CCMoveBy::create(3,CCPointMake(-800,180));


随机移动的6条线路

	int r = rand()%6;
	switch(r)
	{
	case 0:
		fielderSprite1->runAction(at1);
		fielderSprite1->ccat=at1;
		fielderSprite1->mark=1;break;
	case 1:
		fielderSprite1->runAction(at2);
		fielderSprite1->ccat=at2;
		fielderSprite1->mark=2;break;
	case 2:
		fielderSprite1->runAction(at3);
		fielderSprite1->ccat=at3;
		fielderSprite1->mark=3;break;
	case 3:
		fielderSprite1->runAction(at4);
		fielderSprite1->ccat=at4;
		fielderSprite1->mark=4;break;
	case 4:
		fielderSprite1->runAction(at5);
		fielderSprite1->ccat=at5;
		fielderSprite1->mark=5;break;
	case 5:
		fielderSprite1->runAction(at6);
		fielderSprite1->ccat=at6;
		fielderSprite1->mark=6;break;
	}


将定时器在一次创建的守门员都添加到array中,用于后面检测是否与球碰撞了

array->addObject(fielderSprite1);

 

哇!板球 源码分析三,布布扣,bubuko.com

哇!板球 源码分析三

原文:http://blog.csdn.net/oyangyufu/article/details/28040125

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!