How to create the land (hills) like iOS game 'Contre Jour'?

How to create the land (hills) like iOS game Contre Jour? (Using Box2d and OpenGL)

My ideas:

Physics (Box2d)

  1. I think we have array of bodies or fixture.
  2. When we to touch screen, determine touch location.
  3. If the touch location is not far from land, we begin to scan the array of bodies, and are looking for a body with coordinates closest to touch Location.
  4. When case a touch Move, move the right body to a new coordinate (body->SetTransform(...)).

What do you think, efficient to use a large number of bodies? And find for the right body by coordinates?

Graphics (OpenGL)

There is an array of vertices and triangles created by drawing the land (hills)? Is this true?

How to create the land (hills) like iOS game 'Contre Jour'?

-------------Problems Reply------------

You can use the function b2World::QueryAABB to get a list of the fixtures in a given area, then check those for the best option. The Box2D testbed does this to find out which fixture to grab with the mouse so you could check out that source code. See also:

To move the body you can indeed use SetTransform, which would be good if the object does not need to interact with anything along the way. Another option might be to SetLinearVelocity to a velocity that will move the body to the dragged-to point in one time step. This is a better method if you want a continuous drag with the object being able to bump into things as it moves, because it does not teleport the body instantly to the finger position. If the body is a bullet body then it also prevents the user from dragging things through other objects, eg a static wall. Remember to set the velocity to zero when the finger is lifted :)

Category:objective c Views:1080 Time:2012-01-30

Related post

  • Any tips on how to create apps that run on iOS 3 and iOS 4? 2010-09-30

    Hey, I'm developing an iPhone application and my target is 3GS and 4G devices. iOS 4 introduces methods thats deal with multitasking and newer methods to deal with foreground/background lifecycle events. These new methods aren't available in iOS 3 wh

  • Creating one static library for iOS and simulator for distribution 2010-12-01

    If you create a static library for iOS do you have to distribute the header file(s) with it or is there another way to get it to work? Currently I have a single my_lib.a file for both device and simulator but when I drag it into another test app to u

  • creating an update loop in iOS 2011-03-03

    What is the best way to create an update loop in iOS where I can repeatedly call various modules that wish to update as quickly as possible? Is CADisplayLink essentially the best object to use when you want to know how much time has passed between sc

  • Can we create multiple navigation controllers in iOS? 2012-03-07

    I am a little bit confused about navigation controllers. In one navigation controller, a large amount of view controllers are present. I have seen so many examples with one navigation controller. Can we create multiple navigation controllers in iOS a

  • How to create a landing page with OpenCart, using OpenCart only? 2013-05-10

    What if one would want to create a landing page/home page for opencart? How does someone will supposed to do that? A landing page or home page, using only opencart and no other means. -- Clarification. What I meant of Home Page is it's literal meanin

  • Rails - Creating a Landing Page, which is different than the Web App 2010-10-22

    I'm rails I've been building a web app. But the web app is completely different than what the landing page (sign in, register, about, etc should look like) How do rails developers handle this? Different layouts? Different CSS files? etc.. what's clea

  • Best method to create complex custom interface for IOS 2010-11-15

    I'd like to understand which is the best solution to draw custom interface for IOS application. I know that it's not easy to answer this question directly with code, but i think that it would be great get generic answers... only to understand in whic

  • How can I create objective-C Framework for iOS Application 2011-03-22

    I am in the middle of creating some generic classes that can be reusable for lot of application. For Eg: Share Functions - if we need this functionality in a project then we currently I need to add a group of classes into that project and display the

  • Creating video from scratch in iOS 2011-04-25

    I've got an app where the user shoots some video, enters a title for it, and picks a music track. I've got the music dubbing working with AVMutableComposition, but the titling is a bad hack -- just a view overlaid on the MPMoviePlayerViewController.

  • How to create ad-hoc network from iOS 2011-05-17

    I'm looking for info on how to programmatically create an ad-hoc network from within an app on an iOS device. I've heard that this is possible in 4.3 with the hotspot feature but I'm not looking to tether. I'm also open to options involving jailbreak

  • Can we create a back button like iOS in Android using the custom shape API 2011-06-19

    I would like to know if we can customise a button to show like the Apple iOS button in Android? The button that I would like to draw is If this is possible, can someone give me the pointers to it. Thanks. --------------Solutions------------- Yes, it

  • How to create the required certificates for iOS Development? 2011-07-30

    I have registered for the Apple Developer Program and I am now able to login into the portal. I am a very newbie to App development for iPhone, however, I have read a few tutorials and blogs. My question is how can I generate the certificate for my i

  • How do I create custom error domains for iOS applications? 2011-08-12

    I am a newbie to programming in objective-C for iOS applications. How do I create my own error domains and error codes for use in my own application? --------------Solutions------------- According to the Error Handling Programming Guide: You can crea

  • Creating animated progress bar in iOS 2011-09-29

    I am trying to make a custom animated bar graph for an iPad application (i.e., bar height increases to set level when activated). I am quite new to iOS development and I just want to get feedback on how to approach this task. I am trying to play arou

  • How to create "web forms" natively in iOS app? 2011-10-17

    I would like to know how to create a web form in native iOS code. Take a look at Twitter and Facebook's login forms: Twitter uses <label>username</label> while Facebook uses <input type="text" placeholder="Email" />. I just don't kn

  • How to create self-signed ipa for iOS apps? 2011-11-09

    I want to create a self-signed IPA using XCode for an iOS app I have written. I want to ship the ipa to customer who can sign the app and create an ipa using his code signature. Can someone help me with this ? P.S: I know how to codesign an applicati

  • How to create a form dynamically in iOS 2011-11-28

    Pre Assumption : Having template of quotation form in place I am working on a use case in creating a quotation document dynamically with the edited data(collected within the application) to be saved and sent it as a attachment through a mail. So my q

  • Creating Resizable Image / Rectangle in iOS - Objective C 2011-12-28

    I am wondering if anyone has developed a "crop" style box that a user can interact with in iOS? Specifically, I am looking for something like: but without the actual crop functionality. Any assistance would be great. --------------Solutions----------

  • How to create a scheduled update in iOS 2011-12-30

    I want to create a schedule update to my ios, lets say for example every five days my app will fetch something to the internet and update the database I also want user to set the interval. I want to know where to start and any guides out there? Thank

Copyright (C), All Rights Reserved.

processed in 0.174 (s). 11 q(s)