Set Action Based on iPad 3 vs iPad 1 or 2

ellfireellfire Member Posts: 187
edited May 2012 in Working with GS (Mac)
Does anyone have a way to set an action based on which type of device it is being executed on? I have an intro sequence that syncs images to a soundtrack. When viewed on an iPad 1 or 2 with the lower res graphics, it's fine. When viewing on an iPad 3 with the new retina graphics, it looses sync. If I adjust the sync for iPad 3 I think it will throw off the iPad 1 and 2. Is there a way I can set the action that plays the soundtrack to start at one time for iPad 3 and another for other iPads? Thanks as always.

Best Answer

  • MarkOnTheIronMarkOnTheIron Posts: 1,447
    Accepted Answer
    Create an index attribute called RetinaDisplay (you can also use a boolean but I prefer indexes). Then on the scene where you want to check what device you're on add an actor (or use one that's already there) and make sure to add an image to it. Then on that actor add this:

    Rule:
    -When attribute self.Image contains @2x
    --Change attribute game.RetinaDisplay to 1

    If the attribute is 1 then you should be 100% sure you're on a device with a retina display. This is only a theory and it should work only on adhocs (and Appstore build) and ONLY if the Resolution Independence option is checked.

Answers

  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    At the start of your game spawn for 1 second an actor every 0 seconds and use an attribute to count how many are spawned this number should be higher in newer devices. Credits to Tshirtbooth for it.



  • patapplepatapple Member Posts: 873
    There isn't a direct way to view the device name or generation
  • ellfireellfire Member Posts: 187
    edited May 2012
    At the start of your game spawn for 1 second an actor every 0 seconds and use an attribute to count how many are spawned this number should be higher in newer devices. Credits to Tshirtbooth for it.

    Interesting. Do we think this would work between iPad 2 and 3 because they are running the same CPU? And does anyone have more info on where best to hide this test? I am not using a splash screen in my game, so that's out. Maybe bury it in the menu section?
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Usually it's best to hide it in the splash screen, but if you don't use it you can also put it in your menu scene or whenever you want. Just make sure it's before the scene where you need to differentiate the rules :)

  • ellfireellfire Member Posts: 187
    Okay. Based on @MarkOnTheIron 's suggestion of @tshirtbooth 's idea, I think I may have a slightly simpler way to test a device. Need to test it out first, and I'll report back.

    Too bad there wasn't an action that can examine pixel density to identify the device. I use a single line of script in HTML 5 pages that swaps in a retina version of the site if it is being displayed on an iPad 3 or iPhone 4+.
  • ellfireellfire Member Posts: 187
    if only GS would give us an attribute

    if device.ID is = or greater then ipad2
    do this ...

    :(
    I heartily agree.
  • GraphicWarehouseGraphicWarehouse Member Posts: 927
    doesn't that mean universal builds?
  • ellfireellfire Member Posts: 187
    Ok, so my test in theory works, but in practicality, fails. My variation on the @tshirtbooth method is as follows.

    1. I created a game attribute called hw_test.
    2. Created an actor and installed it into my first screen. If hw_test = 0, the actor takes the hw_test attribute and increases it by 1 as many times as it can in one second. At 1.1 seconds, it saves the value which can be reloaded later.
    3. When the game is subsequently launched, the value is loaded and the test doesn't need to run again.

    Fairly simple, and it does work. The problem, as I hypothesized earlier, is that the iPad 2 and 3 have the same CPU, so the values are too close to create a hardware breaking point. (Ex. iPad three was 29, and iPad 2 was 28.) You could sneeze and get either one to fluctuate up a point or two. I was hoping for a bigger spread.

    Any other ideas on how this might work? In other weird news, both an iPad 2 or 3 scored better than my MacBook air.
  • MarkOnTheIronMarkOnTheIron Member Posts: 1,447
    Here's a foolish suggestion.

    On your project you can use the resolution independence option that will create smaller versions of your images and append a "@2x" to the bigger ones.

    What if you have an actor with an image and check with a rule if self.Image contains "@2x"?

  • ellfireellfire Member Posts: 187
    @MarkOnTheIron - An interesting idea. Can you give an example of what the code for that might look like? I can't quite wrap my head around how you might execute it.
  • ellfireellfire Member Posts: 187
    Okay, now I get it. Sounds full proof in theory. I'll mock it up and give it a try once they get the whole publishing Retina versions bug worked out.
Sign In or Register to comment.