Panda Pig • Patty original or translated works. Welcome reprint, Reprint please indicate the source.
If you feel that the writing is not good please tell me, if you feel good please support a lot of praise. Thank you! Hopy;)
Prepare to shorten rebound bar material
Similar to the previous one, we followed the same material as a shortened rebound stick.
Open Spritebuilder, create a new STICKSHORTER.CCB file, press to draw its sprite frame and physical object:
Note that when you zoom in and out of the original bounce stick in AI, just zoom in one Direction along the x-axis, or the y-axis will become larger, which is not what we want.
Create a shortened prop star
We use the Red stars to shorten the props, so it's written in Spawstar:
case brkColorRed: star = [Star starWithType:starTypeStickShorter]; break;
In GAMESCENE.M, in the code where the Stars collide with the bounce stick, add the following code:
casestarTypeStickShorter: @synchronized(self){ [selfscheduleBlock:^(CCTimer *timer){ [StardoStickShorterWork:self.stickInGameScene]; delay:0]; } break;
Well, finally, let's go back to STAR.M and add the Dostickshorterwork method:
+ (void) Dostickshorterwork: (Stick *) stick{gamescene *gamescene = [Gamescene Sharedgamescene];Ccphysicsnode *physicsworld = (ccphysicsnode*) stick. Parent;@synchronized (Gamescene) {if ([stick. Nameisequaltostring:@"Stickshorter"]) {return;} if ([Stick. Nameisequaltostring:@"Sticklonger"]) {Stick *sticknormal = [Stick sticknormal];Sticknormal. Position= Stick. Position;[Stick removefromparent];[Physicsworld Removechild:stick Cleanup:yes];[Physicsworld Addchild:sticknormal];Gamescene. Stickingamescene= Sticknormal;Return;}} cgpoint Position = Stick. Position;__block Stick *stickshorter;@synchronized (gamescene) {stickshorter = [Stick Stickshorter];[Stick removefromparent];[Physicsworld Removechild:stick Cleanup:yes];Stickshorter. Position= Position;[Physicsworld Addchild:stickshorter];Stickshorter. Visible= NO;Gamescene. Stickingamescene= Stickshorter;Ccsprite *sticknode = (ccsprite*) [Ccbreader load:@"Elements/sticknode"];Sticknode. Position= Stickshorter. Position;[Gamescene Addchild:sticknodeZ: -];Ccactionscaleto *shorteraction = [Ccactionscaleto actionwithduration:0.4F ScaleX:0.5F ScaleY:1.0F;Ccactioncallblock *blk = [Ccactioncallblock actionwithblock:^{[Sticknode removefromparent];Stickshorter. Visible= YES;}];Ccactionsequence *seq = [Ccactionsequence Actions:shorteraction,blk,nil];[Sticknode Runaction:seq];} [Stickshorter scheduleblock:^ (Cctimer *timer) {@synchronized (gamescene) {Stick *sticknormal = [Stic K Sticknormal];Sticknormal. Position= Stickshorter. Position;[Stickshorter Removefromparent];[Physicsworld Addchild:sticknormal];Gamescene. Stickingamescene= Sticknormal;}} Delay:Ten];}
We can compare with the variable length of the corresponding code, the basic is the same.
The following compile runs the game, the effect is as follows:
You can add more effects in shorter and longer lengths, open your brain hole, kids ' shoes;)
(no.00004) iOS implementation brick game (13): retractable freely, I am Ruyi Golden cudgel (under)!