@@ -1434,11 +1434,11 @@ SpriteFrameTest::SpriteFrameTest()
1434
1434
//
1435
1435
// Animation using Sprite Sheet
1436
1436
//
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 ) );
1439
1439
1440
1440
CCSpriteSheet* spritesheet = CCSpriteSheet::spriteSheetWithFile (" animations/grossini.png" );
1441
- spritesheet->addChild (sprite );
1441
+ spritesheet->addChild (m_pSprite1 );
1442
1442
addChild (spritesheet);
1443
1443
1444
1444
NSMutableArray<CCSpriteFrame*>* animFrames = new NSMutableArray<CCSpriteFrame*>(15 );
@@ -1452,16 +1452,18 @@ SpriteFrameTest::SpriteFrameTest()
1452
1452
}
1453
1453
1454
1454
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 ) ) );
1456
1456
1457
1457
// to test issue #732, uncomment the following line
1458
- // sprite.flipX = true;
1458
+ m_pSprite1->setFlipX (false );
1459
+ m_pSprite1->setFlipY (false );
1460
+
1459
1461
//
1460
1462
// Animation using standard Sprite
1461
1463
//
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 );
1465
1467
1466
1468
1467
1469
NSMutableArray<CCSpriteFrame*>* moreFrames = new NSMutableArray<CCSpriteFrame*>(20 );
@@ -1484,14 +1486,17 @@ SpriteFrameTest::SpriteFrameTest()
1484
1486
CCAnimation *animMixed = CCAnimation::animationWithName (" dance" , 0 .2f , moreFrames);
1485
1487
1486
1488
1487
- sprite2 ->runAction (CCRepeatForever::actionWithAction ( CCAnimate::actionWithAnimation (animMixed, false ) ) );
1489
+ m_pSprite2 ->runAction (CCRepeatForever::actionWithAction ( CCAnimate::actionWithAnimation (animMixed, false ) ) );
1488
1490
1489
1491
animFrames->release ();
1490
1492
moreFrames->release ();
1491
1493
1492
1494
// 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 ;
1495
1500
}
1496
1501
1497
1502
void SpriteFrameTest::onExit ()
@@ -1510,6 +1515,51 @@ std::string SpriteFrameTest::title()
1510
1515
return " Sprite vs. SpriteSheet animation" ;
1511
1516
}
1512
1517
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
+
1513
1563
// ------------------------------------------------------------------
1514
1564
//
1515
1565
// SpriteOffsetAnchorRotation
0 commit comments