IOS games: simple Plants vs. Zombies

Source: Internet
Author: User

1. Fast texture

 

 

 

Gameplay: If 10 botnets are killed, go through the next close. When you click to enter the next close, the speed of the botnets increases.

If there are 15 botnets in the house, they will lose.

Play audio when you click to kill a zombie, and play audio or background music when you win or lose.

 

 

Ii. business logic and knowledge points

 

1. There are two main classes: Class 1: homepage display class rootviewcontroller: uiimageview; Class 2: zombie class: zombieview: uiimageview.

2. play audio: # import <avfoundation/avaudioplayer. h>, which must be added,

 

 

Nsstring * deadpath = [[nsbundle mainbundle] pathforresource: @ "lose" oftype: @ "MP3"]; nsurl * deadurl = [nsurl fileurlwithpath: deadpath]; deadplayer = [[avaudioplayer alloc] initwithcontentsofurl: deadurl error: Nil]; [deadplayer preparetoplay];

3. Reminder box:

Uialertview * Alert = [[uialertview alloc] initwithtitle: @ "! ! "Message: @" You lost! "Delegate: Nil cancelbuttontitle: @" OK! "Otherbuttontitles: Nil]; [alert show];

[Alert release];

4. Import the package, which is generally placed in the. M file to prevent cross-compilation.

5. Timer,

Timer = [nstimer scheduledtimerwithtimeinterval: time target: Self

Selector: @ selector (MOVE) userinfo: Nil repeats: Yes];

 

[Timer invalidate]; // stop the timer

6. ry transform (matrix transformation)

// Change the zombie size

-(Void) changesize {// difficult, ry transform (matrix transformation) cgaffinetransform T = cgaffinetransformmakescale (2.0, 2.0); // scale the image and increase the animation [uiview animatewithduration: 0.35 animations: ^ {self. transform = T;} completion: ^ (bool finished) {// zoom out the animation [uiview animatewithduration: 0.35 animations: ^ {cgaffinetransform T1 = cgaffinetransformscale (self. transform, 0.5, 0.5); self. transform = T1;} completion: ^ (bool finished) {[self removefromsuperview] ;}];}

 

 

Related Article

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.