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-08-08 18:02:17 +08:00
|
|
|
https://axys1.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.
|
|
|
|
****************************************************************************/
|
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
//
|
|
|
|
// Bug-12847.cpp
|
|
|
|
// cocos2d_tests
|
|
|
|
//
|
|
|
|
// Issue: https://github.com/cocos2d/cocos2d-x/issues/12847
|
|
|
|
// Please test in iPhone5 +
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
#include "Bug-12847.h"
|
|
|
|
|
2022-07-11 17:50:21 +08:00
|
|
|
USING_NS_AX;
|
2015-07-22 13:42:10 +08:00
|
|
|
|
2019-04-04 16:13:17 +08:00
|
|
|
Bug12847Layer::Bug12847Layer()
|
|
|
|
{
|
|
|
|
_projection = Director::getInstance()->getProjection();
|
|
|
|
}
|
|
|
|
|
|
|
|
Bug12847Layer::~Bug12847Layer()
|
|
|
|
{
|
|
|
|
Director::getInstance()->setProjection(_projection);
|
|
|
|
}
|
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
bool Bug12847Layer::init()
|
|
|
|
{
|
|
|
|
if (BugsTestBase::init())
|
|
|
|
{
|
2015-07-23 06:08:36 +08:00
|
|
|
Director::getInstance()->setProjection(Director::Projection::_2D);
|
2015-07-22 13:42:10 +08:00
|
|
|
auto _visibleSize = Director::getInstance()->getVisibleSize();
|
2021-12-28 16:06:23 +08:00
|
|
|
|
|
|
|
// Create with Sprite
|
2015-07-22 13:42:10 +08:00
|
|
|
{
|
|
|
|
sprite1 = Sprite::create("Images/bug12847_sprite.png");
|
|
|
|
sprite1->getTexture()->setAliasTexParameters();
|
2021-12-28 16:06:23 +08:00
|
|
|
sprite1->setPosition(Vec2(_visibleSize.width / 3, 50.0f));
|
2015-07-22 13:42:10 +08:00
|
|
|
this->addChild(sprite1, 1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
sprite2 = Sprite::create("Images/bug12847_sprite.png");
|
|
|
|
sprite2->getTexture()->setAliasTexParameters();
|
|
|
|
sprite2->setPosition(sprite1->getPosition() + Vec2(0.0f, sprite1->getContentSize().height));
|
|
|
|
this->addChild(sprite2, 1);
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
// Create with SpriteFrame
|
2015-07-22 13:42:10 +08:00
|
|
|
{
|
|
|
|
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("Images/bug12847_spriteframe.plist");
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
sprite3 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png");
|
|
|
|
sprite3->getTexture()->setAliasTexParameters();
|
2021-12-28 16:06:23 +08:00
|
|
|
sprite3->setPosition(Vec2(_visibleSize.width * 2 / 3, 50.0f));
|
2015-07-22 13:42:10 +08:00
|
|
|
this->addChild(sprite3, 1);
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
sprite4 = Sprite::createWithSpriteFrameName("bug12847_sprite2.png");
|
|
|
|
sprite4->getTexture()->setAliasTexParameters();
|
|
|
|
sprite4->setPosition(sprite3->getPosition() + Vec2(0.0f, sprite3->getContentSize().height));
|
|
|
|
this->addChild(sprite4, 1);
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
this->scheduleUpdate();
|
|
|
|
return true;
|
|
|
|
}
|
2021-12-28 16:06:23 +08:00
|
|
|
|
2015-07-22 13:42:10 +08:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bug12847Layer::update(float dt)
|
|
|
|
{
|
2015-07-23 06:08:36 +08:00
|
|
|
sprite1->setPositionY(sprite1->getPositionY() + 0.01f);
|
|
|
|
sprite2->setPositionY(sprite2->getPositionY() + 0.01f);
|
|
|
|
sprite3->setPositionY(sprite3->getPositionY() + 0.01f);
|
|
|
|
sprite4->setPositionY(sprite4->getPositionY() + 0.01f);
|
2015-07-22 13:42:10 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
void Bug12847Layer::onEnter()
|
|
|
|
{
|
|
|
|
BugsTestBase::onEnter();
|
|
|
|
Director::getInstance()->setClearColor(Color4F::RED);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Bug12847Layer::onExit()
|
|
|
|
{
|
|
|
|
Director::getInstance()->setClearColor(Color4F::BLACK);
|
|
|
|
BugsTestBase::onExit();
|
|
|
|
}
|