Chipmunk tutorial 1-settings

Source: Internet
Author: User

Setup

 

Before we start practical application, we need to set up a project so that we can focus on chipmunk.

Open xcode, create a new project, and use the 'view-based 'application.ProgramTemplate to create a simple application. After the application is started, a view is displayed.

We generally need to import the chipmunk file. This task will be completed in several steps, including creating a static library and connecting to our project. In this example, we simply copy the files we need to the project folder. Then download the latest chipmunkCode, Decompress, this folder will contain multiple files, examples and documents, but we only need to pay attention to the contents in the SRC folder.

Before importing these files, we recommend that you create a new group in other source. Then, use 'add existing file' and select the SRC folder mentioned above. Make sure to select 'Copy items into the destination group's folder (if needed) '. After these steps, if you compile the project, no error will be reported.

Now we have completed the setup step. We don't plan to use any game engine, and create several images to represent our objects. Although you can use a changed code to replace these images, I suggest you use images and code to reduce your misunderstanding of the Code.

 

Now open View Controller and add this to the file.

View plaincopy to clipboardprint?
  1. Uiimageview * floor;// Holds our floor Image
  2. Uiimageview * ball;// Holds our ball Image

 

Then, the viewdidload is uninjected to implement the following code. You can copy the code and put it after [Super viewdidload:

View plaincopy to clipboardprint?
  1. Floor = [[uiimageview alloc] initwithimage: [uiimage imagenamed :@"Floor.png"];
  2. Floor. Center = cgpointmake (160,350 );
  3. Ball = [[uiimageview alloc] initwithimage: [uiimage imagenamed :@"Ball.png"];
  4. Ball. Center = cgpointmake (160,230 );
  5. [Self. View addsubview: Floor];
  6. [Self. View addsubview: Ball];

After running the startup program, you will see the two pictures I mentioned above in the program.

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.