Example #1
0
// on "init" you need to initialize your instance
bool Level01::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }
    
	m_visibleSize = Director::getInstance()->getVisibleSize();
	m_floorPoint = m_visibleSize.height / 4.6;
    Point origin = Director::getInstance()->getVisibleOrigin();

	auto wall = DrawNode::create();
	wall->drawSolidRect(Vec2(0, 0), Vec2(m_visibleSize.width, m_visibleSize.height), Color4F::GRAY);
	this->addChild(wall);

	setPlayer();
	setBG();
	
	animCache();
	auto shade = DrawNode::create();
	shade->drawSolidRect(Vec2(0, 0), Vec2(m_visibleSize.width, m_visibleSize.height), Color4F(0, 0, 0, 180));
	this->addChild(shade);
	idle();
	eventHandler();
	m_enterButton = ui::Button::create("img/button.png");
	m_enterButton->setScale(0.6);
	m_enterButton->setTitleColor(Color3B::WHITE);
	m_enterButton->setTitleFontName("fonts/ant-maru.ttf");
	m_enterButton->setTitleFontSize(45);
	m_enterButton->setTitleText("入る");
	m_enterButton->setVisible(false);
	m_enterButton->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height / 10));
	this->addChild(m_enterButton);


	m_sadmanMsg = ui::Button::create("img/button.png");
	m_sadmanMsg->setScale(1);
	m_sadmanMsg->setTitleColor(Color3B::WHITE);
	m_sadmanMsg->setTitleFontName("fonts/ant-maru.ttf");
	m_sadmanMsg->setTitleFontSize(26);
	m_sadmanMsg->setTitleText("トナリノヘアガアカルクテ");
	m_sadmanMsg->setVisible(false);
	m_sadmanMsg->setPosition(Vec2(m_visibleSize.width / 2, m_visibleSize.height / 10));
	m_sadmanMsg->setEnabled(false);
	this->addChild(m_sadmanMsg);

	this->scheduleUpdate();
	
    return true;
}
// on "init" you need to initialize your instance
bool HelloWorld::init()
{
    //////////////////////////////
    // 1. super init first (default)
    if ( !Layer::init() )
    {
        return false;
    }
    
    // get window sizes
    auto origin = Director::getInstance()->getVisibleOrigin();
    auto winSize = Director::getInstance()->getVisibleSize();
    
    // Create a DrawNode rect filled with grey
    auto background = DrawNode::create();
    background->drawSolidRect(origin, winSize, Color4F(0.6, 0.6, 0.6, 1.0));
    this->addChild(background);
    
    // create player sprite with image name, position it 10% from left and centered vertically
    _player = Sprite::create("player.png");
    _player->setPosition(Vec2(winSize.width * 0.1, winSize.height * 0.5));
    this->addChild(_player);
    
    // seed the rand() engine
    srand((unsigned int)time(nullptr));
    
    // add a monster every 1.5 seconds
    this->schedule(schedule_selector(HelloWorld::addMonster), 1.5); // C++ function pointer?!
    
    return true;
}
Example #3
0
void LayerMoveRangeManage::setDrawDataRect(std::string tagname, Vec2 startPos, Vec2 endedPos, bool isOpen)
{
	auto data = drawMap_[tagname];
	auto node = data->drawnode;
	int col1 = startPos.x;
	int row1 = startPos.y;
	int col2 = endedPos.x;
	int row2 = endedPos.y;
	if (col1 > col2){
		int temp = col1;
		col1 = col2;
		col2 = temp;
	}
	if (row1 > row2){
		int temp = row1;
		row1 = row2;
		row2 = temp;
	}
	node->clear();
	if (col1 >= 0 && row1 >= 0 && col2 >= 0 && row2 >= 0){
		node->drawSolidRect(gridPosChangeToGLPosStart(Vec2(col1, row1), isOpen), gridPosChangeToGLPosEnd(Vec2(col2, row2), isOpen),
			Color4F(Color4B(0x9F, 0x79, 0xEE, 0x9F)));
	}
	data->row1 = row1;
	data->col1 = col1;
	data->row2 = row2;
	data->col2 = col2;
	data->isDraw = true;
}
Example #4
0
void LayerMoveRangeManage::setDrawDataRect(DrawData* data)
{
	auto node = data->drawnode;
	node->clear();
	if (data->col1 >= 0 && data->row1 >= 0 && data->col2 >= 0 && data->row2 >= 0){
		node->drawSolidRect(gridPosChangeToGLPosStart(Vec2(data->col1, data->row1), false), gridPosChangeToGLPosEnd(Vec2(data->col2, data->row2), false),
			Color4F(Color4B(0x9F, 0x79, 0xEE, 0x9F)));
	}
}
Example #5
0
//create this image from another image (tile)
void Image::createThisFromImage(Image &image, int tileNum /*=-1*/, int iAlpha /*=-1*/)
{
	cleanUp();
	_init = Surface::create(image.tileW(), image.tileH(), iAlpha);
	//prefill with alpha colour so the final surface contains it where curr see through
	drawSolidRect(0,0,image.tileW(),image.tileH(), ALPHA_COLOUR);
	if (-1 == tileNum) 
		setTileSize(); 
	else 
		setTileSize(image.tileW(), image.tileH());
	blitFrom(&image, tileNum);	//into this newly created 'copy'
}
Example #6
0
// on "init" you need to initialize your instance
bool GameOver::init()
{
    //////////////////////////////
    // 1. super init first
    if ( !Layer::init() )
    {
        return false;
    }

	
	auto winSize = Director::getInstance()->getVisibleSize();
	auto origin = Director::getInstance()->getVisibleOrigin();
	//auto winSize = Director::getInstance()->getVisibleSize();
    
	auto bg = DrawNode::create();
	bg->drawSolidRect(origin, winSize, Color4F::GREEN);
	//this->addChild(bg);
	auto bg1 = Sprite::create("image/bg2.png");
	bg1->setScaleX(1.5);
	bg1->setAnchorPoint(Vec2(0, 0));
	this->addChild(bg1);

	/*auto gameOver = MenuItemFont::create("Game Over !", CC_CALLBACK_1(GameOver::exitGame, this));
	gameOver->setColor(Color3B::RED);
	gameOver->setFontName("fonts/Marker Felt.tff");*/
	auto gameOver = MenuItemImage::create("image/gameover.png", "image/gameover.png", CC_CALLBACK_1(GameOver::exitGame, this));
    
	auto menu = Menu::createWithItems(gameOver, "\0");
	this->addChild(menu);

	
	auto boom = Sprite::create("image/boom4.png");
	boom->setPosition(winSize.width / 3, winSize.height / 3);
	//boom->setScale(1.7);
	//boom->setColor(Color3B::YELLOW);
	this->addChild(boom);
	CocosDenshion::SimpleAudioEngine::getInstance()->pauseBackgroundMusic();
	CocosDenshion::SimpleAudioEngine::getInstance()->playEffect("audio/gameOver.mp3");
	//Sleep(3000);
	//CocosDenshion::SimpleAudioEngine::getInstance()->playBackgroundMusic("audio/menuBg.wav");

    return true;
}
Example #7
0
void ComDraw::drawSolidRect(double x, double y, double w, double h, string color, double fog) {
	CCPoint origin = ccp(x, SCREEN_HEIGHT - y);
	CCPoint destination = ccp(x + w, SCREEN_HEIGHT - (y + h));
	drawSolidRect(origin, destination, color, fog);
}
Example #8
0
void WorldUIView::drawBg(){
	color(Color(0, 140.0/255.0, 240.0/255.0));
	drawSolidRect(Rectf(rect.x, rect.y, rect.xEnd, rect.yEnd));
}	
Example #9
0
void DetectingStage::drawGameplay(){

	//get guage
	Rectf gaugeRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight());
	//Texture guageTexture = guageVid_.getTexture();


	/////calculate phub time
	//int phubH = timePhub_ / 3600;
	//int phubM = (timePhub_ / 60) % 60;
	//int phubS = timePhub_ % 60;

	//
	//string phubHS,phubMS, phubSS,phubString;
	//if (phubH < 10) phubHS = "0" + toString(phubH);
	//else phubHS = toString(phubH);

	//if (phubM < 10) phubMS = "0" + toString(phubM);
	//else phubMS = toString(phubM);

	//if (phubS < 10) phubSS = "0" + toString(phubS);
	//else phubSS = toString(phubS);

	//phubString = phubHS + ":" + phubMS + ":" + phubSS;

	/////calculate talk string
	//int talkH = timeTalk_ / 3600;
	//int talkM = (timeTalk_ / 60) % 60;
	//int talkS = timeTalk_ % 60;

	//string talkHS, talkMS, talkSS, talkString;
	//if (talkH < 10) talkHS = "0" + toString(talkH);
	//else talkHS = toString(talkH);

	//if (talkM < 10) talkMS = "0" + toString(talkM);
	//else talkMS = toString(talkM);

	//if (talkS < 10) talkSS = "0" + toString(talkS);
	//else talkSS = toString(talkS);

	//talkString = talkHS + ":" + talkMS + ":" + talkSS;

	////draw red green rect
	//Rectf greenRect = Rectf(0.0f, 0.0f, getWindowWidth(), getWindowHeight()*0.15f);
	//Rectf redRect = Rectf(0.0f, 0.0f, (getWindowWidth()*currentRatio_), getWindowHeight()*0.15f);
	//gl::color(67.f/255.f, 193.f/255.f, 30.f/255.f);
	////drawSolidRect(greenRect);
	//gl::color(255.f/255.f, 54.f/255.f, 54.f/255.f);
	////drawSolidRect(redRect);
	//gl::color(1, 1, 1);
	
	
	//draw sticker
	for (int i = 0; i < persons_.size(); i++){
		if (persons_[i].unDetectFrame <= 180){
			if (!isDebugMode) gl::color(Color(CM_HSV, facesColor_[persons_[i].id], 0.77f, 0.96f));
			else gl::color(1, 1, 1, 0.5);
			//choose correct texture for each person
			Texture stickerTexture;

			if (persons_[i].getLook() == LOOKUP) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = smileLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileLeftFemaleTexture_;
					else stickerTexture = smileLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = smileMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileFemaleTexture_;
					else stickerTexture = smileTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = smileRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = smileRightFemaleTexture_;
					else stickerTexture = smileRightTexture_;
				}
			}
			else if (persons_[i].getLook() == LOOKDOWN) {
				if (persons_[i].segtion == LEFT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousLeftMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousLeftFemaleTexture_;
					else stickerTexture = seriousLeftTexture_;
				}
				else if (persons_[i].segtion == CENTER) {
					if (persons_[i].gender == MALE) stickerTexture = seriousMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousFemaleTexture_;
					else stickerTexture = seriousTexture_;
				}
				else if (persons_[i].segtion == RIGHT) {
					if (persons_[i].gender == MALE) stickerTexture = seriousRightMaleTexture_;
					else if (persons_[i].gender == FEMALE) stickerTexture = seriousRightFemaleTexture_;
					else stickerTexture = seriousRightTexture_;
				}
			}
			else if (persons_[i].getLook() == TURNLEFT) {
				if (persons_[i].gender == MALE) stickerTexture = turnLeftMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnLeftFemaleTexture_;
				else stickerTexture = turnLeftTexture_;
			}
			else if (persons_[i].getLook() == TURNRIGHT) {
				if (persons_[i].gender == MALE) stickerTexture = turnRightMaleTexture_;
				else if (persons_[i].gender == FEMALE) stickerTexture = turnRightFemaleTexture_;
				else stickerTexture = turnRightTexture_;
			}

			//adjust position and size
			float frameSize = 120.f / (persons_[i].depth / 1000.f);
			float ratio = frameSize / 60.f;

			Vec2f shift(param_shiftX_, param_shiftY_);
			Vec2f scale(param_scale_ * ratio, param_scale_ * ratio);

			//calibrate position for each segment
			Vec2f calShift(0, 0);
			if (persons_[i].segtion == LEFT) calShift.x = -param_calShift_;
			else if (persons_[i].segtion == RIGHT) calShift.x = param_calShift_;
			else calShift.x = 0;

			Rectf stickerRect = Rectf(persons_[i].center - scale + shift + calShift,
				persons_[i].center + scale + shift + calShift);
			if (stickerTexture){
				glEnable(GL_BLEND);
				glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
				displayArea_.draw(stickerTexture, stickerRect);
				ci::gl::disableAlphaBlending();
				glDisable(GL_BLEND);
			}
		}
	}
	gl::color(1, 1, 1);

	//draw guage
	if (gaugeTexture_){
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		displayArea_.draw(gaugeTexture_, gaugeRect);
		//draw rect
		float gaugeRatio = gaugeValue_ / gaugeMax_;
		Rectf blackRect = Rectf(getWindowWidth()*0.287f, getWindowHeight()*0.1485f, (getWindowWidth()*0.287f) + (getWindowWidth()*0.475f*gaugeRatio), getWindowHeight()*0.171f);
		gl::color(0, 0, 0);
		drawSolidRect(blackRect);
		gl::color(1, 1, 1);

		float hurtRatio = hurtValue_ / hurtMax_;
		float fade = 0;
		float maxStage = 30.0;
		if (bloodStage_ > 100) bloodStage_ = 0;
		if (bloodStage_ < maxStage) fade = bloodStage_ * (100.f / maxStage);
		else {
			int diff = bloodStage_ - maxStage;
			fade = 100 - (diff * (100.f / (100.f - maxStage)));
		}
		bloodStage_++;

		gl::color(1, 1, 1, (fade / 100.f)*hurtRatio);

		int second = getElapsedSeconds();
		int result = second % 2;
		if (bloodTexture_ && status_ == PHUB){
			Rectf bloodRect = Rectf(0, 0, getWindowWidth(), getWindowHeight());
			displayArea_.draw(bloodTexture_, bloodRect);
			timeStamp_ = second;
		}

		glDisable(GL_BLEND);
	}

	gl::color(1, 1, 1);
}
Example #10
0
void RectDrawNode::redraw() {
  drawSolidRect(Vec2(-mSize.width / 2, -mSize.height / 2),
                Vec2(mSize.width / 2, mSize.height / 2),
                Color4F(getColor()));
}