Getting started with Alibaba iOS-Bull & #39; Eye games

Source: Internet
Author: User
Tags rounds

Description

Bull's Eye games are very cool demos in http://www.raywenderlich.com/store/ios-apprentice
Follow this tutorial step by step to do it will have Bull's Eye, source code can be found on the official website, or from my github clone, https://github.com/avenwu/bulleye.git

First show:

The rule is simple. Each time a random number of 1-is generated, the player slides to the nearest position through the slider and then clicks the Hit me button. The score is displayed, and the score is accumulated after Scroe, the current number of rounds is displayed in the Round. the reset button is displayed on the left to clear the score and number of rounds.

Target

Development Environment: Xcode5.0.2/Mac Pro

Implementation

The game is very simple. Use xcode to create a singleview project and check the ARC. In this way, the newly created Project has already packaged a large majority of files. If you have used Android, in fact, we will find that iOS app development is quite easy to use. Is the project structure of Bull's Eye,

Compared with the newly created Project, a view controller is added. In my understanding, this view controller can be analogous to an Activity in Android. It is mainly used to process the interaction logic of UI controls, for example, to update the text content of a label and add an Action event, the difference is that we do not set the corresponding view explicitly, instead, drag a view controller in the storyboard and specify its class as our class file. ViewController corresponds to the main game interface, and AboutViewController corresponds to the description page.


Click Main. storyboard, and then the editing area will display an editing area similar to the xml layout in Android. Here we select the desired controller and add the required UI control on it, all the controls can be found in the UIKit on the right side, drag them to the page, adjust the parameters, and display the content, size, and color, drag a New view controller and bind it to AboutViewController, and then place the corresponding control,

Now the page layout is complete, but how do we control a control from the code? In Android, I can create an id for the control and then findViewbyId in the activity. In iOS, I use OutLet and Action to do this. As for the meanings and operations of the two, there are a lot of related information, so I won't be so embarrassed here.

Now let's start coding and open ViewController. h: This is our header file, which declares the Slider, label, and Action methods. They are all bound to the UI control and can be seen from the small concentric circle mark on it.

Now open ViewController. m, his implementation file, and implement various functions. showAlert is triggered when the Hitme button is clicked. Let's bring up a dialog box to display the current score.

Basic iOS

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.