Note that there are some explanatory texts on larger screens.

plurals
  1. POGoogle Maps iOS Racing Game Collision Detection?
    primarykey
    data
    text
    <p>I am making a driving game for the iOS, where a car (UIView) is put on top of the google maps ios api. I am having trouble detecting collisions with the car and the grey buildings that appear on the map.</p> <p>I have been trying to do it by pixel color i.e. checking if the pixel color, just ahead of the car, is the color of a buildings roof (grey). There is no direct access to an iPhones pixel color, so I am using the google maps screenshot method to get an image and get the pixel color from that. The problem is, is that I can only take a screen shot of the screen I just left. I am using <code>mapImage = [GMSScreenshot screenshotOfMainScreen];</code>. I have also tried getting the window and screen and calling <code>mapImage = [GMSScreenshot screenshotOfScreen:topWindow.screen];</code> Both have the same effect. </p> <p>What is a solution to this problem? Can you think of a better way of handling collisions for this situation? Does reverse geocoding have the ability to detect the tops of buildings vs streets? Thanks for any and all help!</p> <p>EDIT: Images: <img src="https://i.stack.imgur.com/l2nHw.png" alt=""> Interface Builder: Left is the main menu, right is the game. The Ui image view in the upper left corner is set as the current screen shot image for referencing purposes. This how I knew It was off</p> <p><img src="https://i.stack.imgur.com/toyP3.png" alt=""> Game Play, As you can see, it is only presenting the previous menu. </p> <p>My viewdidLoad function: Not much other than this thats related to getting the image.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; cameraPosition = CLLocationCoordinate2DMake(42.271291, -83.729918); moveDistance = .00055; cA = [UIColor colorWithRed:.937255 green:.921569 blue:.886275 alpha:1]; camera = [GMSCameraPosition cameraWithLatitude:cameraPosition.latitude longitude:cameraPosition.longitude zoom:19 bearing:0 viewingAngle:0]; mapView_ = [GMSMapView mapWithFrame:CGRectMake(0, 0, 480, 300) camera:camera]; mapView_.myLocationEnabled = NO; [self.view addSubview:mapView_]; car_ = [[Car alloc] initWithFrame:CGRectMake(240, 150, 13, 29) withImage:[UIImage imageNamed:@"carA-01.png"]]; [self.view addSubview:car_]; [self.view addSubview:controllerView]; updateClock = [NSTimer scheduledTimerWithTimeInterval:(1/20) target:self selector:@selector(update) userInfo:nil repeats:YES]; crashClock = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(checkCrash) userInfo:nil repeats:YES]; UIWindow *topWindow = [[UIApplication sharedApplication].windows objectAtIndex:0]; mapImage = [GMSScreenshot screenshotOfScreen:topWindow.screen]; // mapImage = [GMSScreenshot screenshotOfMainScreen]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload