#在蓝懿学习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