mirror of https://github.com/axmolengine/axmol.git
move ZwoptexTest to SpriteTest (better add it to the SpriteTest section as removing) (#2180)
* move/delete stuff * Update CMakeLists.txt
This commit is contained in:
parent
bf4ef2ff83
commit
2bf320edda
|
@ -130,7 +130,6 @@ list(APPEND GAME_HEADER
|
|||
Source/ActionsEaseTest/ActionsEaseTest.h
|
||||
Source/ParallaxTest/ParallaxTest.h
|
||||
Source/testBasic.h
|
||||
Source/ZwoptexTest/ZwoptexTest.h
|
||||
Source/CurlTest/CurlTest.h
|
||||
Source/ConfigurationTest/ConfigurationTest.h
|
||||
Source/CurrentLanguageTest/CurrentLanguageTest.h
|
||||
|
@ -364,7 +363,6 @@ list(APPEND GAME_SOURCE
|
|||
Source/ImGuiTest/ImGuiTest.cpp
|
||||
Source/VisibleRect.cpp
|
||||
Source/VibrateTest/VibrateTest.cpp
|
||||
Source/ZwoptexTest/ZwoptexTest.cpp
|
||||
Source/SpriteFrameCacheTest/SpriteFrameCacheTest.cpp
|
||||
Source/controller.cpp
|
||||
Source/ZipTest/ZipTests.cpp
|
||||
|
|
|
@ -142,6 +142,7 @@ SpriteTests::SpriteTests()
|
|||
ADD_TEST_CASE(SpriteWithImageDataTest1);
|
||||
ADD_TEST_CASE(SpriteWithImageDataTest2);
|
||||
ADD_TEST_CASE(SpriteWithImageDataTest3);
|
||||
ADD_TEST_CASE(ZwoptexGenericTest);
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------
|
||||
|
@ -5975,3 +5976,121 @@ std::string SpriteWithImageDataTest3::subtitle() const
|
|||
{
|
||||
return "no sprite due to empty key";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ZwoptexGenericTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void ZwoptexGenericTest::onEnter()
|
||||
{
|
||||
ZwoptexTest::onEnter();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini-generic.plist");
|
||||
|
||||
auto layer1 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121);
|
||||
layer1->setPosition(Vec2(s.width / 2 - 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
|
||||
addChild(layer1);
|
||||
|
||||
sprite1 =
|
||||
Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_01.png"));
|
||||
sprite1->setPosition(Vec2(s.width / 2 - 80, s.height / 2));
|
||||
addChild(sprite1);
|
||||
|
||||
sprite1->setFlippedX(false);
|
||||
sprite1->setFlippedY(false);
|
||||
|
||||
auto layer2 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121);
|
||||
layer2->setPosition(Vec2(s.width / 2 + 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
|
||||
addChild(layer2);
|
||||
|
||||
sprite2 = Sprite::createWithSpriteFrame(
|
||||
SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_generic_01.png"));
|
||||
sprite2->setPosition(Vec2(s.width / 2 + 80, s.height / 2));
|
||||
addChild(sprite2);
|
||||
|
||||
sprite2->setFlippedX(false);
|
||||
sprite2->setFlippedY(false);
|
||||
|
||||
schedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::startIn05Secs), 1.0f);
|
||||
|
||||
sprite1->retain();
|
||||
sprite2->retain();
|
||||
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
void ZwoptexGenericTest::startIn05Secs(float dt)
|
||||
{
|
||||
unschedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::startIn05Secs));
|
||||
schedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::flipSprites), 0.5f);
|
||||
}
|
||||
|
||||
static int spriteFrameIndex = 0;
|
||||
void ZwoptexGenericTest::flipSprites(float dt)
|
||||
{
|
||||
counter++;
|
||||
|
||||
bool fx = false;
|
||||
bool fy = false;
|
||||
int i = counter % 4;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
fx = false;
|
||||
fy = false;
|
||||
break;
|
||||
case 1:
|
||||
fx = true;
|
||||
fy = false;
|
||||
break;
|
||||
case 2:
|
||||
fx = false;
|
||||
fy = true;
|
||||
break;
|
||||
case 3:
|
||||
fx = true;
|
||||
fy = true;
|
||||
break;
|
||||
}
|
||||
|
||||
sprite1->setFlippedX(fx);
|
||||
sprite2->setFlippedX(fx);
|
||||
sprite1->setFlippedY(fy);
|
||||
sprite2->setFlippedY(fy);
|
||||
|
||||
if (++spriteFrameIndex > 14)
|
||||
{
|
||||
spriteFrameIndex = 1;
|
||||
}
|
||||
|
||||
char str1[32] = {0};
|
||||
char str2[32] = {0};
|
||||
sprintf(str1, "grossini_dance_%02d.png", spriteFrameIndex);
|
||||
sprintf(str2, "grossini_dance_generic_%02d.png", spriteFrameIndex);
|
||||
sprite1->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str1));
|
||||
sprite2->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str2));
|
||||
}
|
||||
|
||||
ZwoptexGenericTest::~ZwoptexGenericTest()
|
||||
{
|
||||
sprite1->release();
|
||||
sprite2->release();
|
||||
auto cache = SpriteFrameCache::getInstance();
|
||||
cache->removeSpriteFramesFromFile("zwoptex/grossini.plist");
|
||||
cache->removeSpriteFramesFromFile("zwoptex/grossini-generic.plist");
|
||||
}
|
||||
|
||||
std::string ZwoptexGenericTest::title() const
|
||||
{
|
||||
return "Zwoptex Tests";
|
||||
}
|
||||
|
||||
std::string ZwoptexGenericTest::subtitle() const
|
||||
{
|
||||
return "Coordinate Formats, Rotation, Trimming, flipX/Y";
|
||||
}
|
||||
|
|
|
@ -973,4 +973,29 @@ public:
|
|||
virtual std::string subtitle() const override;
|
||||
};
|
||||
|
||||
class ZwoptexTest : public TestCase
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class ZwoptexGenericTest : public ZwoptexTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ZwoptexGenericTest);
|
||||
|
||||
virtual ~ZwoptexGenericTest();
|
||||
|
||||
virtual void onEnter() override;
|
||||
void flipSprites(float dt);
|
||||
void startIn05Secs(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
ax::Sprite* sprite1;
|
||||
ax::Sprite* sprite2;
|
||||
int counter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,151 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://axmol.dev/
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#include "ZwoptexTest.h"
|
||||
#include "../testResource.h"
|
||||
|
||||
using namespace ax;
|
||||
|
||||
ZwoptexTests::ZwoptexTests()
|
||||
{
|
||||
ADD_TEST_CASE(ZwoptexGenericTest);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------
|
||||
//
|
||||
// ZwoptexGenericTest
|
||||
//
|
||||
//------------------------------------------------------------------
|
||||
void ZwoptexGenericTest::onEnter()
|
||||
{
|
||||
ZwoptexTest::onEnter();
|
||||
|
||||
auto s = Director::getInstance()->getWinSize();
|
||||
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini.plist");
|
||||
SpriteFrameCache::getInstance()->addSpriteFramesWithFile("zwoptex/grossini-generic.plist");
|
||||
|
||||
auto layer1 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121);
|
||||
layer1->setPosition(Vec2(s.width / 2 - 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
|
||||
addChild(layer1);
|
||||
|
||||
sprite1 =
|
||||
Sprite::createWithSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_01.png"));
|
||||
sprite1->setPosition(Vec2(s.width / 2 - 80, s.height / 2));
|
||||
addChild(sprite1);
|
||||
|
||||
sprite1->setFlippedX(false);
|
||||
sprite1->setFlippedY(false);
|
||||
|
||||
auto layer2 = LayerColor::create(Color4B(255, 0, 0, 255), 85, 121);
|
||||
layer2->setPosition(Vec2(s.width / 2 + 80 - (85.0f * 0.5f), s.height / 2 - (121.0f * 0.5f)));
|
||||
addChild(layer2);
|
||||
|
||||
sprite2 = Sprite::createWithSpriteFrame(
|
||||
SpriteFrameCache::getInstance()->getSpriteFrameByName("grossini_dance_generic_01.png"));
|
||||
sprite2->setPosition(Vec2(s.width / 2 + 80, s.height / 2));
|
||||
addChild(sprite2);
|
||||
|
||||
sprite2->setFlippedX(false);
|
||||
sprite2->setFlippedY(false);
|
||||
|
||||
schedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::startIn05Secs), 1.0f);
|
||||
|
||||
sprite1->retain();
|
||||
sprite2->retain();
|
||||
|
||||
counter = 0;
|
||||
}
|
||||
|
||||
void ZwoptexGenericTest::startIn05Secs(float dt)
|
||||
{
|
||||
unschedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::startIn05Secs));
|
||||
schedule(AX_SCHEDULE_SELECTOR(ZwoptexGenericTest::flipSprites), 0.5f);
|
||||
}
|
||||
|
||||
static int spriteFrameIndex = 0;
|
||||
void ZwoptexGenericTest::flipSprites(float dt)
|
||||
{
|
||||
counter++;
|
||||
|
||||
bool fx = false;
|
||||
bool fy = false;
|
||||
int i = counter % 4;
|
||||
|
||||
switch (i)
|
||||
{
|
||||
case 0:
|
||||
fx = false;
|
||||
fy = false;
|
||||
break;
|
||||
case 1:
|
||||
fx = true;
|
||||
fy = false;
|
||||
break;
|
||||
case 2:
|
||||
fx = false;
|
||||
fy = true;
|
||||
break;
|
||||
case 3:
|
||||
fx = true;
|
||||
fy = true;
|
||||
break;
|
||||
}
|
||||
|
||||
sprite1->setFlippedX(fx);
|
||||
sprite2->setFlippedX(fx);
|
||||
sprite1->setFlippedY(fy);
|
||||
sprite2->setFlippedY(fy);
|
||||
|
||||
if (++spriteFrameIndex > 14)
|
||||
{
|
||||
spriteFrameIndex = 1;
|
||||
}
|
||||
|
||||
char str1[32] = {0};
|
||||
char str2[32] = {0};
|
||||
sprintf(str1, "grossini_dance_%02d.png", spriteFrameIndex);
|
||||
sprintf(str2, "grossini_dance_generic_%02d.png", spriteFrameIndex);
|
||||
sprite1->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str1));
|
||||
sprite2->setSpriteFrame(SpriteFrameCache::getInstance()->getSpriteFrameByName(str2));
|
||||
}
|
||||
|
||||
ZwoptexGenericTest::~ZwoptexGenericTest()
|
||||
{
|
||||
sprite1->release();
|
||||
sprite2->release();
|
||||
auto cache = SpriteFrameCache::getInstance();
|
||||
cache->removeSpriteFramesFromFile("zwoptex/grossini.plist");
|
||||
cache->removeSpriteFramesFromFile("zwoptex/grossini-generic.plist");
|
||||
}
|
||||
|
||||
std::string ZwoptexGenericTest::title() const
|
||||
{
|
||||
return "Zwoptex Tests";
|
||||
}
|
||||
|
||||
std::string ZwoptexGenericTest::subtitle() const
|
||||
{
|
||||
return "Coordinate Formats, Rotation, Trimming, flipX/Y";
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
|
||||
|
||||
https://axmol.dev/
|
||||
|
||||
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:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
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.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ZWOPTEX_TEST_H__
|
||||
#define __ZWOPTEX_TEST_H__
|
||||
|
||||
#include "../BaseTest.h"
|
||||
|
||||
DEFINE_TEST_SUITE(ZwoptexTests);
|
||||
|
||||
class ZwoptexTest : public TestCase
|
||||
{
|
||||
public:
|
||||
};
|
||||
|
||||
class ZwoptexGenericTest : public ZwoptexTest
|
||||
{
|
||||
public:
|
||||
CREATE_FUNC(ZwoptexGenericTest);
|
||||
|
||||
virtual ~ZwoptexGenericTest();
|
||||
|
||||
virtual void onEnter() override;
|
||||
void flipSprites(float dt);
|
||||
void startIn05Secs(float dt);
|
||||
|
||||
virtual std::string title() const override;
|
||||
virtual std::string subtitle() const override;
|
||||
|
||||
protected:
|
||||
ax::Sprite* sprite1;
|
||||
ax::Sprite* sprite2;
|
||||
int counter;
|
||||
};
|
||||
|
||||
#endif // __ZWOPTEX_TEST_H__
|
|
@ -119,7 +119,6 @@
|
|||
#include "UITest/UITest.h"
|
||||
#include "UserDefaultTest/UserDefaultTest.h"
|
||||
#include "VibrateTest/VibrateTest.h"
|
||||
#include "ZwoptexTest/ZwoptexTest.h"
|
||||
#include "SpriteFrameCacheTest/SpriteFrameCacheTest.h"
|
||||
#include "ZipTest/ZipTests.h"
|
||||
#if defined(AX_PLATFORM_PC) || (AX_TARGET_PLATFORM == AX_PLATFORM_ANDROID) || defined(__EMSCRIPTEN__)
|
||||
|
|
Loading…
Reference in New Issue