Exemple #1
0
bool Fish::init(int type)
{
	srand(time(NULL));
	//精灵鱼
	if(type < 25)
	{
		sprintf(fish_tmp_char,"fish_%d_0.png",type);
		fish_type = type;
	}else if(type == 25)
	{
		sprintf(fish_tmp_char,"fish_24_%d_0.png",StaticFunc::roomType + 1);
		fish_type = 25 + StaticFunc::roomType;
	}

	yy_pianyi = Vec2(yy_fish_distance * sin(0) , yy_fish_distance * - cos(0) );

	_fishSprite = Sprite::createWithSpriteFrameName(fish_tmp_char);
	_fishSprite_yy = Sprite::createWithSpriteFrameName(fish_tmp_char);
	_fishSprite_yy->setPosition((Vec2)_fishSprite->getContentSize()/2 + yy_pianyi);
	_fishSprite->addChild(_fishSprite_yy,-1);
	this->addChild(_fishSprite);
 
	sprintf(fish_tmp_char,"fish_animation_%d",fish_type);
	_fishSprite->runAction(RepeatForever::create( Animate::create(AnimationCache::getInstance()->getAnimation(fish_tmp_char))));
  
	//鱼的阴影
	auto shader_program = GLProgram::createWithFilenames("shadow.vsh", "shadow.fsh");
	shader_program->use();
	shader_program->setUniformsForBuiltins();
	_fishSprite_yy->setGLProgram(shader_program);
	_fishSprite_yy->runAction(RepeatForever::create( Animate::create(AnimationCache::getInstance()->getAnimation(fish_tmp_char))));
 
 
	//初始化数据
	bDead = false;
	fish_cur_frame = 0;

	m_iX = 0;
	m_iY = 0;
	m_iXMov = 0;
	m_iYMov = 0;

	sprintf(fish_tmp_char,"weight%d",type);
	fish_width = STATIC_DATA_INT(fish_tmp_char);

	sprintf(fish_tmp_char,"height%d",type);
	fish_hight = STATIC_DATA_INT(fish_tmp_char);
 
	return true;
}
Exemple #2
0
//-----------------------------------------------------------------------------
//todo 预载入资源,实现StartScene后将其删除
void CGameScene::preloadResources()
{
	CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("fishingjoy_resource.plist");

	//以下代码创建了两个不同的动画帧序列,使用时获取动画可以这么做:CCAnimation* animation = CCAnimationCache::sharedAnimationCache()->animationByName(const char* name);
	int frameCount = STATIC_DATA_INT("fish_frame_count");
	for (int type = k_Fish_Type_Red; type < k_Fish_Type_Count; type++)
	{
		//以下代码会创建animation失败
// 		CCAnimation* fishAnimation = CCAnimation::create();
// 		for (int i = 0; i < frameCount; i++)
// 		{
// 			fishAnimation->addSpriteFrameWithFileName(
// 				CCString::createWithFormat(STATIC_DATA_STRING("fish_frame_name_format"), type, i)->getCString());
// 		}

		CCArray* spriteFramesArray = CCArray::createWithCapacity(frameCount);
		for (int i = 0; i < frameCount; i++)
		{
			CCString* fileName = CCString::createWithFormat(STATIC_DATA_STRING("fish_frame_name_format"), type, i);
			CCSpriteFrame* spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(fileName->getCString());
			spriteFramesArray->addObject(spriteFrame);
		}
		CCAnimation* fishAnimation = CCAnimation::createWithSpriteFrames(spriteFramesArray);
		fishAnimation->setDelayPerUnit(STATIC_DATA_FLOAT("fish_frame_delay"));		
		CCString* animationName = CCString::createWithFormat(STATIC_DATA_STRING("fish_animation"),type);
		CCAnimationCache::sharedAnimationCache()->addAnimation(fishAnimation, animationName->getCString());
	}

	
}
void FishingJoyData::reset(){
	//╤ах║д╛хож╣
	int gold = STATIC_DATA_INT("default_gold");
	this->setGold(gold);
	this->setIsBeginner(true);
	this->setMusicVolume(1);
	this->setSoundVolume(1);
	this->flush();
}
void FishingJoy::reset()
{
	int gold = STATIC_DATA_INT(GameConfig::GOLD);
	this->setGold(gold);

	this->setSoundVolume(STATIC_DATA_FLOAT(GameConfig::SOUND_VALUME));

	this->setMusicVolume(STATIC_DATA_FLOAT(GameConfig::MUSIC_VALUME));

	this->flush();
}
Exemple #5
0
//todo 预载入资源,实现StartScene后将其删除
void GameScene::preloadResources()
{
    CCSpriteFrameCache::sharedSpriteFrameCache()->addSpriteFramesWithFile("fishingjoy_resource.plist");
    
    int frameCount = STATIC_DATA_INT("fish_frame_count");
    for (int type = k_Fish_Type_Red; type < k_Fish_Type_Count; type++) {
        CCArray* spriteFrames = CCArray::createWithCapacity(frameCount);
        for(int i = 0;i < frameCount;i++){
            CCString* filename = CCString::createWithFormat(STATIC_DATA_STRING("fish_frame_name_format"),type,i);
            CCSpriteFrame* spriteFrame = CCSpriteFrameCache::sharedSpriteFrameCache()->spriteFrameByName(filename->getCString());
            spriteFrames->addObject(spriteFrame);
        }
        CCAnimation* fishAnimation = CCAnimation::createWithSpriteFrames(spriteFrames);
        fishAnimation->setDelayPerUnit(STATIC_DATA_FLOAT("fish_frame_delay"));
        CCString* animationName = CCString::createWithFormat(STATIC_DATA_STRING("fish_animation"), type);
        CCAnimationCache::sharedAnimationCache()->addAnimation(fishAnimation, animationName->getCString());
    }
}
Exemple #6
0
bool Enemy::init()
{
    xSpeed = kCJStartSpeed;
    hp = kCJHP;
    atk = kCJATK;
    isCollision = false;
    actionRange = 1;
    
    bloodBar = CCSprite::createWithSpriteFrameName("blood_bar.png");
    bloodBar->setScaleX(0.3);
    bloodBar->setScaleY(0.5);
    bloodBar->setAnchorPoint(ccp(0.5, 0));
    
    if (STATIC_DATA_INT("debug") == 1)
    {
        drawCollisionLine();
    }
    return true;
}
Exemple #7
0
bool Soldier::init()
{
    //isS6 = false;
    //isS9 = false;
    
//    isScheduledForRemove = false;
    isCollision = false;
    curActionCount = 0;
//    delayCount = 0;
    
    bloodBar = CCSprite::createWithSpriteFrameName("blood_bar.png");
    bloodBar->setScaleX(0.3);
    bloodBar->setScaleY(0.5);
    bloodBar->setAnchorPoint(ccp(0.5, 0));
    
    if (STATIC_DATA_INT("debug") == 1)
    {
        drawCollisionLine();
    }
    return true;
}