2018-01-29 16:25:32 +08:00
|
|
|
/****************************************************************************
|
|
|
|
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2022-02-24 18:45:25 +08:00
|
|
|
https://adxeproject.github.io/
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2018-01-29 16:25:32 +08:00
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
****************************************************************************/
|
|
|
|
|
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
|
|
|
{
|
2021-12-28 16:06:23 +08:00
|
|
|
// Add label
|
2014-04-09 23:31:05 +08:00
|
|
|
auto label = Label::createWithTTF("Answer 1", "fonts/arial.ttf", 12);
|
2011-07-08 11:22:35 +08:00
|
|
|
label->setTag(100);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
// Add the background
|
|
|
|
auto size = Director::getInstance()->getWinSize();
|
2013-08-16 16:05:27 +08:00
|
|
|
auto corner = Sprite::create("Images/bugs/corner.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
int width = size.width * 0.9f - (corner->getContentSize().width * 2);
|
|
|
|
int height = size.height * 0.15f - (corner->getContentSize().height * 2);
|
2013-08-16 16:05:27 +08:00
|
|
|
auto layer = LayerColor::create(Color4B(255, 255, 255, 255 * .75), width, height);
|
2014-05-15 01:07:09 +08:00
|
|
|
layer->setPosition(Vec2(-width / 2, -height / 2));
|
2011-07-08 11:22:35 +08:00
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
// First button is blue,
|
|
|
|
// Second is red
|
|
|
|
// Used for testing - change later
|
2011-07-08 11:22:35 +08:00
|
|
|
static int a = 0;
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2011-07-08 11:22:35 +08:00
|
|
|
if (a == 0)
|
2013-07-08 18:11:32 +08:00
|
|
|
label->setColor(Color3B::BLUE);
|
2011-07-08 11:22:35 +08:00
|
|
|
else
|
|
|
|
{
|
2013-07-24 06:20:22 +08:00
|
|
|
log("Color changed");
|
2013-07-08 18:11:32 +08:00
|
|
|
label->setColor(Color3B::RED);
|
2011-07-08 11:22:35 +08:00
|
|
|
}
|
|
|
|
a++;
|
|
|
|
addChild(layer);
|
|
|
|
|
2021-12-28 16:06:23 +08:00
|
|
|
corner->setPosition(Vec2(-(width / 2 + corner->getContentSize().width / 2),
|
|
|
|
-(height / 2 + corner->getContentSize().height / 2)));
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(corner);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto corner2 = Sprite::create("Images/bugs/corner.png");
|
2014-05-15 01:07:09 +08:00
|
|
|
corner2->setPosition(Vec2(-corner->getPosition().x, corner->getPosition().y));
|
2013-09-16 20:38:03 +08:00
|
|
|
corner2->setFlippedX(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(corner2);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto corner3 = Sprite::create("Images/bugs/corner.png");
|
2014-05-15 01:07:09 +08:00
|
|
|
corner3->setPosition(Vec2(corner->getPosition().x, -corner->getPosition().y));
|
2013-09-16 20:38:03 +08:00
|
|
|
corner3->setFlippedY(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(corner3);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto corner4 = Sprite::create("Images/bugs/corner.png");
|
2014-05-15 01:07:09 +08:00
|
|
|
corner4->setPosition(Vec2(corner2->getPosition().x, -corner2->getPosition().y));
|
2013-09-16 20:38:03 +08:00
|
|
|
corner4->setFlippedX(true);
|
|
|
|
corner4->setFlippedY(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(corner4);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto edge = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge->setScaleX(width);
|
2021-12-28 16:06:23 +08:00
|
|
|
edge->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2),
|
|
|
|
corner->getPosition().y));
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(edge);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto edge2 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge2->setScaleX(width);
|
2021-12-28 16:06:23 +08:00
|
|
|
edge2->setPosition(Vec2(corner->getPosition().x + (corner->getContentSize().width / 2) + (width / 2),
|
|
|
|
-corner->getPosition().y));
|
2013-09-16 20:38:03 +08:00
|
|
|
edge2->setFlippedY(true);
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(edge2);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto edge3 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge3->setRotation(90);
|
|
|
|
edge3->setScaleX(height);
|
2021-12-28 16:06:23 +08:00
|
|
|
edge3->setPosition(Vec2(corner->getPosition().x,
|
|
|
|
corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(edge3);
|
|
|
|
|
2013-08-16 16:05:27 +08:00
|
|
|
auto edge4 = Sprite::create("Images/bugs/edge.png");
|
2011-07-08 11:22:35 +08:00
|
|
|
edge4->setRotation(270);
|
|
|
|
edge4->setScaleX(height);
|
2021-12-28 16:06:23 +08:00
|
|
|
edge4->setPosition(Vec2(-corner->getPosition().x,
|
|
|
|
corner->getPosition().y + (corner->getContentSize().height / 2) + (height / 2)));
|
2011-07-08 11:22:35 +08:00
|
|
|
addChild(edge4);
|
|
|
|
|
|
|
|
addChild(label);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|