#在蓝懿学习iOS的日子 #day10

Source: Internet
Author: User

#在蓝懿学习iOS的日子 #day10 made a big game today, covering this time to learn to wash the knowledge, the page of the switch string, as well as variable groups and traversal knowledge points.

1, display build view add background, create a Select Hero view, add a button click into the next selection hero view;

2, in the Hero view to build a view to add a background, create a Hero hero class, the different hero J connected to the same button, set tag to distinguish Hero class; Click button to enter the game page,

3, the game page to add the mobile background view,

-(void) initbg{

// Add background image

self. Bgiv1 = [[uiimageview alloc] initwithframe:cgrectmake ( 00self. View. Frame. Size. Widthself. View. Frame. Size. Height

The second picture is on the top of the first one,y:-self.view.frame.size.height .

Self.BgIV2= [[Uiimageview Alloc]initwithframe:cgrectmake ( 0self. View. Frame. Size. Heightself. View. Frame. Size. Widthself. View. Frame. Size. Height

self. BgIV1. Image = [UIImage imagenamed:@ "img_bg_level_1.jpg"];

self. BgIV2. Image = [UIImage imagenamed:@ "img_bg_level_1.jpg"];

// Insert a child control to a location and place the background image at the bottom

[self. View Insertsubview:self. BgIV1 atindex:0];

[self. View Insertsubview:self. BgIV2 atindex:0];

// Move set TImer for background

[nstimer scheduledtimerwithtimeinterval:1.0/ target: Self selector:@selector(MOVEBG) userInfo:nil repeats:YES] ;

}

-(void) movebg{

// set picture to move Down y+1

    self. Bgiv1. Center = cgpointmake (self.< Span class= "S5" >bgiv1. Center. Xself. Bgiv1. Center. Y+1)

self. BgIV2. Center = Cgpointmake(self. BgIV2. Center. X, self. BgIV2. Center. Y+1);

// Two images of cohesion

if (self. BgIV1. Center. Y>=self. View. Frame. Size. Height*1.5) {

self. BgIV1. Center = Cgpointmake(self. BgIV1. Center. x,-self. View. Frame. Size. Height/2);

}

if (self. BgIV2. Center. Y>=self. View. Frame. Size. Height*1.5) {

self. BgIV2. Center = Cgpointmake(self. BgIV2. Center. x,-self. View. Frame. Size. Height/2);

}

#在蓝懿学习iOS的日子 #day10

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.