@@ -37,32 +37,34 @@ class $modify(FriendsPlayLayer, PlayLayer) {
3737 void setupHasCompleted () {
3838 PlayLayer::setupHasCompleted ();
3939
40- auto delay = randng::get (3 . f );
40+ auto delay = randng::get (1 . 25f );
4141 log::trace (" Friend will visit after {} seconds" , delay);
4242
4343 scheduleOnce (schedule_selector (FriendsPlayLayer::showAFriend), delay);
4444 };
4545
4646 void showAFriend (float ) {
47- auto rnd = randng::fast ();
47+ auto const uiSize = m_uiLayer-> getScaledContentSize ();
4848
49- float xA = -125 .f ; // starting x pos
50- float xB = getScaledContentWidth () + 125 .f ; // ending x pos
49+ auto xA = -125 .f ; // starting x pos
50+ auto xB = uiSize. width + 125 .f ; // ending x pos
5151
52- if ((static_cast <float >(rnd) / 2 ) <= 50.0 ) {
52+ if ((static_cast <float >(randng::fast ()) / 2 . f ) <= 50 .f ) {
5353 xA = xB;
5454 xB = -125 .f ;
5555 }; // swap sides
5656
5757 auto rA = randng::pc ();
5858 auto rB = randng::pc ();
5959
60- float yA = getScaledContentHeight () * rA; // starting height pos
61- float yB = getScaledContentHeight () * rB; // ending height pos
60+ log::trace (" friend starts at height percent {} and ends at {}" , rA, rB);
61+
62+ auto yA = uiSize.height * rA; // starting height pos
63+ auto yB = uiSize.height * rB; // ending height pos
6264
6365 auto friendSpr = CCSprite::createWithSpriteFrameName (s_friends[randng::get (s_friends.size () - 1 )]);
6466 friendSpr->setPosition ({xA, yA});
65- friendSpr->setScale (1.25 * (rB + rA));
67+ friendSpr->setScale (0 . 875f * (rB + rA));
6668 friendSpr->setRotation (180 .f * (yA * yB)); // random rotation
6769
6870 auto dur = 12 .5f * rA;
@@ -80,11 +82,11 @@ class $modify(FriendsPlayLayer, PlayLayer) {
8082 };
8183
8284 void cleanupFriend (CCNode* sender) {
83- if (sender) sender-> removeFromParent ( );
85+ cue::resetNode (sender);
8486 };
8587
8688 void scheduleNextFriend () {
87- auto delay = randng::get (5 . f );
89+ auto delay = randng::get (2 . 5f );
8890 log::trace (" Friend will visit again after {} seconds" , delay);
8991
9092 scheduleOnce (schedule_selector (FriendsPlayLayer::showAFriend), delay);
0 commit comments