Skip to content

Commit 09a83bb

Browse files
author
natural-law
committed
issue #165
Update the tests code to 0.99.4 release version
1 parent c4c81db commit 09a83bb

File tree

4 files changed

+119
-11
lines changed

4 files changed

+119
-11
lines changed

test_uphone/tests/SchedulerTest/SchedulerTest.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,43 @@ std::string SchedulerUpdateFromCustom::subtitle()
551551
return "Update schedules in 2 secs. Stops 2 sec later. See console";
552552
}
553553

554+
//------------------------------------------------------------------
555+
//
556+
// RescheduleSelector
557+
//
558+
//------------------------------------------------------------------
559+
void RescheduleSelector::onEnter()
560+
{
561+
SchedulerTestLayer::onEnter();
562+
563+
m_fInterval = 1.0f;
564+
m_nTicks = 0;
565+
schedule(schedule_selector(RescheduleSelector::schedUpdate), m_fInterval);
566+
}
567+
568+
std::string RescheduleSelector::title()
569+
{
570+
return "Reschedule Selector";
571+
}
572+
573+
std::string RescheduleSelector::subtitle()
574+
{
575+
return "Interval is 1 second, then 2, then 3...";
576+
}
577+
578+
void RescheduleSelector::schedUpdate(ccTime dt)
579+
{
580+
m_nTicks++;
581+
582+
//CCLOG(@"schedUpdate: %.2f", dt);
583+
if ( m_nTicks > 3 )
584+
{
585+
m_fInterval += 1.0f;
586+
schedule(schedule_selector(RescheduleSelector::schedUpdate), m_fInterval);
587+
m_nTicks = 0;
588+
}
589+
}
590+
554591
//------------------------------------------------------------------
555592
//
556593
// SchedulerTestScene

test_uphone/tests/SchedulerTest/SchedulerTest.h

+13
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,19 @@ class TestNode : public CCNode
141141
NSString* m_pstring;
142142
};
143143

144+
class RescheduleSelector : public SchedulerTestLayer
145+
{
146+
public:
147+
virtual void onEnter();
148+
virtual std::string title();
149+
virtual std::string subtitle();
150+
151+
void schedUpdate(ccTime dt);
152+
private:
153+
float m_fInterval;
154+
int m_nTicks;
155+
};
156+
144157
class SchedulerTestScene : public TestScene
145158
{
146159
public:

test_uphone/tests/SpriteTest/SpriteTest.cpp

+61-11
Original file line numberDiff line numberDiff line change
@@ -1434,11 +1434,11 @@ SpriteFrameTest::SpriteFrameTest()
14341434
//
14351435
// Animation using Sprite Sheet
14361436
//
1437-
CCSprite* sprite = CCSprite::spriteWithSpriteFrameName("grossini_dance_01.png");
1438-
sprite->setPosition( ccp( s.width/2-80, s.height/2) );
1437+
m_pSprite1 = CCSprite::spriteWithSpriteFrameName("grossini_dance_01.png");
1438+
m_pSprite1->setPosition( ccp( s.width/2-80, s.height/2) );
14391439

14401440
CCSpriteSheet* spritesheet = CCSpriteSheet::spriteSheetWithFile("animations/grossini.png");
1441-
spritesheet->addChild(sprite);
1441+
spritesheet->addChild(m_pSprite1);
14421442
addChild(spritesheet);
14431443

14441444
NSMutableArray<CCSpriteFrame*>* animFrames = new NSMutableArray<CCSpriteFrame*>(15);
@@ -1452,16 +1452,18 @@ SpriteFrameTest::SpriteFrameTest()
14521452
}
14531453

14541454
CCAnimation* animation = CCAnimation::animationWithName("dance", 0.2f, animFrames);
1455-
sprite->runAction( CCRepeatForever::actionWithAction( CCAnimate::actionWithAnimation(animation, false) ) );
1455+
m_pSprite1->runAction( CCRepeatForever::actionWithAction( CCAnimate::actionWithAnimation(animation, false) ) );
14561456

14571457
// to test issue #732, uncomment the following line
1458-
// sprite.flipX = true;
1458+
m_pSprite1->setFlipX(false);
1459+
m_pSprite1->setFlipY(false);
1460+
14591461
//
14601462
// Animation using standard Sprite
14611463
//
1462-
CCSprite* sprite2 = CCSprite::spriteWithSpriteFrameName("grossini_dance_01.png");
1463-
sprite2->setPosition( ccp( s.width/2 + 80, s.height/2) );
1464-
addChild(sprite2);
1464+
m_pSprite2 = CCSprite::spriteWithSpriteFrameName("grossini_dance_01.png");
1465+
m_pSprite2->setPosition( ccp( s.width/2 + 80, s.height/2) );
1466+
addChild(m_pSprite2);
14651467

14661468

14671469
NSMutableArray<CCSpriteFrame*>* moreFrames = new NSMutableArray<CCSpriteFrame*>(20);
@@ -1484,14 +1486,17 @@ SpriteFrameTest::SpriteFrameTest()
14841486
CCAnimation *animMixed = CCAnimation::animationWithName("dance", 0.2f, moreFrames);
14851487

14861488

1487-
sprite2->runAction(CCRepeatForever::actionWithAction( CCAnimate::actionWithAnimation(animMixed, false) ) );
1489+
m_pSprite2->runAction(CCRepeatForever::actionWithAction( CCAnimate::actionWithAnimation(animMixed, false) ) );
14881490

14891491
animFrames->release();
14901492
moreFrames->release();
14911493

14921494
// to test issue #732, uncomment the following line
1493-
// sprite2.flipX = true;
1494-
1495+
m_pSprite2->setFlipX(false);
1496+
m_pSprite2->setFlipY(false);
1497+
1498+
schedule(schedule_selector(SpriteFrameTest::startIn05Secs), 0.5f);
1499+
m_nCounter = 0;
14951500
}
14961501

14971502
void SpriteFrameTest::onExit()
@@ -1510,6 +1515,51 @@ std::string SpriteFrameTest::title()
15101515
return "Sprite vs. SpriteSheet animation";
15111516
}
15121517

1518+
std::string SpriteFrameTest::subtitle()
1519+
{
1520+
return "Testing issue #792";
1521+
}
1522+
1523+
void SpriteFrameTest::startIn05Secs(ccTime dt)
1524+
{
1525+
unschedule(schedule_selector(SpriteFrameTest::startIn05Secs));
1526+
schedule(schedule_selector(SpriteFrameTest::flipSprites), 1.0f);
1527+
}
1528+
1529+
void SpriteFrameTest::flipSprites(ccTime dt)
1530+
{
1531+
m_nCounter++;
1532+
1533+
bool fx = false;
1534+
bool fy = false;
1535+
int i = m_nCounter % 4;
1536+
1537+
switch ( i ) {
1538+
case 0:
1539+
fx = false;
1540+
fy = false;
1541+
break;
1542+
case 1:
1543+
fx = true;
1544+
fy = false;
1545+
break;
1546+
case 2:
1547+
fx = false;
1548+
fy = true;
1549+
break;
1550+
case 3:
1551+
fx = true;
1552+
fy = true;
1553+
break;
1554+
}
1555+
1556+
m_pSprite1->setFlipX(fx);
1557+
m_pSprite1->setFlipY(fy);
1558+
m_pSprite2->setFlipX(fx);
1559+
m_pSprite2->setFlipY(fy);
1560+
//NSLog(@"flipX:%d, flipY:%d", fx, fy);
1561+
}
1562+
15131563
//------------------------------------------------------------------
15141564
//
15151565
// SpriteOffsetAnchorRotation

test_uphone/tests/SpriteTest/SpriteTest.h

+8
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,14 @@ class SpriteFrameTest: public SpriteTestDemo
202202
~SpriteFrameTest();
203203
virtual void onExit();
204204
virtual std::string title();
205+
virtual std::string subtitle();
206+
207+
void startIn05Secs(ccTime dt);
208+
void flipSprites(ccTime dt);
209+
private:
210+
CCSprite *m_pSprite1;
211+
CCSprite *m_pSprite2;
212+
int m_nCounter;
205213
};
206214

207215
class SpriteOffsetAnchorRotation: public SpriteTestDemo

0 commit comments

Comments
 (0)