Lite version-Angry Birds

Source: Internet
Author: User

    • First we'll lay out the layout using Sizeclass:

    • Connect here:
@property (weaknonatomicIBOutletUIButton *bird;@property (strongnonatomic) IBOutletCollection(UIImageViewNSArray *ices;

For ice, because we have 4 blocks of ice here, so we're directly connected to an array.

    • Lazy Loading a Uidynamicanimator
@property (strongnonatomic) UIDynamicAnimator *animator;- (UIDynamicAnimator *)animator{    if ( !_animator) {        _animator = [UIDynamicAnimator new];    }    return _animator;}
    • Next, we give a listen to the bird's Click event
- (ibaction) Birdaction: (ID) sender{//Add gravity to birds and ice    Nsmutablearray*TEMPARRM = [NsmutablearrayArray]; [Temparrm AddObject: Self. Bird]; [TEMPARRM Addobjectsfromarray: Self. Ices];    Uigravitybehavior *gravity = [[Uigravitybehavior alloc] INITWITHITEMS:TEMPARRM]; [ Self. AnimatorAddbehavior:gravity];//Add collisions to birds and iceUicollisionbehavior *collision = [[Uicollisionbehavior alloc] INITWITHITEMS:TEMPARRM]; [Collision Settranslatesreferenceboundsintoboundary:YES];//Add screen edge collisionsUibezierpath *path = [Uibezierpath bezierpathwithrect: Self. View. Bounds]; [Collision addboundarywithidentifier:@"Boundstest"Forpath:path]; [ Self. AnimatorAddbehavior:collision];/** uipushbehaviormodecontinuous, continuous force uipushbehaviormodeinstantaneous instantaneous force * *    //Add thrust to the birdUipushbehavior *push = [[Uipushbehavior alloc] initwithitems:@[ Self. Bird] mode:uipushbehaviormodeinstantaneous];//direction of forcePush. Magnitude=5.0; Push. Angle=2* M_PI; [ Self. AnimatorAddbehavior:push];}

Look at the effect:

Can simply realize this little game, we can make the rest of the functions of their own perfect. Thank you

Lite version-Angry Birds

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.