2011-07-08 11:22:35 +08:00
|
|
|
#include "QuestionContainerSprite.h"
|
|
|
|
|
|
|
|
#define kLabelTag
|
|
|
|
|
2012-06-14 05:19:13 +08:00
|
|
|
USING_NS_CC;
|
2011-07-08 11:22:35 +08:00
|
|
|
|
|
|
|
bool QuestionContainerSprite::init()
|
|
|
|
{
|
2013-06-20 14:17:10 +08:00
|
|
|
if (Sprite::init())
|
2011-07-08 11:22:35 +08:00
|
|
|
{
|
|
|
|
//Add label
|
2013-06-20 14:17:10 +08:00
|
|
|
LabelTTF* label = LabelTTF::create("Answer 1", "Arial", 12);
|
2011-07-08 11:22:35 +08:00
|
|
|
label->setTag(100);
|
|
|
|
|
|
|
|
//Add the background
|
2013-06-20 14:17:10 +08:00
|
|
|
Size size = Director::sharedDirector()->getWinSize();
|
|
|
|
Sprite* corner = Sprite::create("Images/bugs/corner.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
|
|
|
|
int width = size.width * 0.9f - (corner->getContentSize().width * 2);
|
|
|
|
int height = size.height * 0.15f - (corner->getContentSize().height * 2);
|
2013-06-20 14:17:10 +08:00
|
|
|
LayerColor* layer = LayerColor::create(ccc4(255, 255, 255, 255 * .75), width, height);
|
2011-07-08 11:22:35 +08:00
|
|
|
layer->setPosition(ccp(-width / 2, -height / 2));
|
|
|
|
|
|
|
|
//First button is blue,
|
|
|
|
//Second is red
|
|
|
|
//Used for testing - change later
|
|
|
|
static int a = 0;
|
|
|
|
|
|
|
|
if (a == 0)
|
|
|
|
label->setColor(ccBLUE);
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CCLog("Color changed");
|
|
|
|
label->setColor(ccRED);
|
|
|
|
}
|
|
|
|
a++;
|
|
|
|
addChild(layer);
|
|
|
|
|
|
|
|
corner->setPosition(ccp(-(width / 2 + corner->getContentSize().width / 2), -(height / 2 + corner->getContentSize().height / 2)));
|
|
|
|
addChild(corner);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* corner2 = Sprite::create("Images/bugs/corner.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
corner2->setPosition(ccp(-corner->getPosition().x, corner->getPosition().y));
|
|
|
|
corner2->setFlipX(true);
|
|
|
|
addChild(corner2);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* corner3 = Sprite::create("Images/bugs/corner.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
corner3->setPosition(ccp(corner->getPosition().x, -corner->getPosition().y));
|
|
|
|
corner3->setFlipY(true);
|
|
|
|
addChild(corner3);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* corner4 = Sprite::create("Images/bugs/corner.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
corner4->setPosition(ccp(corner2->getPosition().x, -corner2->getPosition().y));
|
|
|
|
corner4->setFlipX(true);
|
|
|
|
corner4->setFlipY(true);
|
|
|
|
addChild(corner4);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* edge = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge->setScaleX(width);
|
|
|
|
edge->setPosition(ccp(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), corner->getPosition().y));
|
|
|
|
addChild(edge);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* edge2 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge2->setScaleX(width);
|
|
|
|
edge2->setPosition(ccp(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2), -corner->getPosition().y));
|
|
|
|
edge2->setFlipY(true);
|
|
|
|
addChild(edge2);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* edge3 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge3->setRotation(90);
|
|
|
|
edge3->setScaleX(height);
|
|
|
|
edge3->setPosition(ccp(corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
|
|
|
addChild(edge3);
|
|
|
|
|
2013-06-20 14:17:10 +08:00
|
|
|
Sprite* edge4 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge4->setRotation(270);
|
|
|
|
edge4->setScaleX(height);
|
|
|
|
edge4->setPosition(ccp(-corner->getPosition().x, corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
|
|
|
addChild(edge4);
|
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|