Set Action Based on iPad 3 vs iPad 1 or 2
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
-
MarkOnTheIron Posts: 1,447
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
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+.
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.
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"?