iPhone 4 problem!

@Tom: That’s great news! Looking forward to Evan’s description… just in time because I plan on getting a new iTouch 4 soon so I can start taking advantage of the “retina display” in my projects. [import]uid: 7849 topic_id: 1361 reply_id: 5710[/import]

Thanks Tom! I’m curious to see what you guys have come up with. My only concern with having 2 copies of every graphic is it will make the binary fairly large. Then what happens when you guys enable universal binaries someday (theoretically) - we would need 3 copies of every graphic file. I know I’m jumping the gun here but would it be a reasonable request to have a “resolution independence” option where Corona assumes ALL images in the project are at least twice as big as they will be displayed? So if I have a 200x80 button, my png will be 400x160.

Just a thought.

Dave [import]uid: 8194 topic_id: 1361 reply_id: 5712[/import]

I think that downsizing a sprite in real-time is significantly dropping the effective fps because of increased cpu load. So, we either ask for small game footprint or good performance. Since Corona SDK is minimalistic in footprint but struggles to run smoothly on 60hz, personally I would go for the bigger game size. In other words, I would prefer using double images. This is the solution that most Cocos2d developers also prefer, among the two choices. [import]uid: 7356 topic_id: 1361 reply_id: 5713[/import]

I agree with Magenda. :wink: Can’t wait for this! [import]uid: 7022 topic_id: 1361 reply_id: 5739[/import]

Again, any news? [import]uid: 7022 topic_id: 1361 reply_id: 5902[/import]

Evan updated the online docs to describe the higher resolution mode using Dynamic Image Resolution.
http://developer.anscamobile.com/content/configuring-projects#Dynamic_Image_Resolution

The change adds a new image object that will automatically pick the best graphics for the device: display.newImageRect. If you want to support iPhone and iPhone4 you will need two sets of graphics, normal size for iPhone 3 and 2x resolution images for iPhone 4. You can mix the normal and high resolution images and only use the high resolution where they are really needed.

-Tom [import]uid: 7559 topic_id: 1361 reply_id: 5906[/import]

Very nice - this works great, Tom!

To note, you can also implement your new retina display 114 x 114 icon by naming it Icon@2x.png and dropping it in your project folder… and the same goes for Default.png! (I have @2x setup as my “naming rule” - not positive if that matters or not.)

Now, any ideas on how we could get the ui module to work with high res buttons? [import]uid: 4621 topic_id: 1361 reply_id: 5909[/import]

Does this work with movieclip or sprite sheet? [import]uid: 8486 topic_id: 1361 reply_id: 5918[/import]

I can’t figure out how to use it, in fact doesn’t seem to work for now. [import]uid: 7022 topic_id: 1361 reply_id: 5922[/import]

@Alwayk

It works great for me, in fact I update my entire application to high-resolution graphics today and it looks amazing on iPhone 4 now.

You’re using Beta 8, right?
You made the imageSuffix update to your config.lua, right?
You named the higher resolution graphics with the same imageSuffix you defined in config.lua, right?
You changed display.newImage to display.newImageRect, right?

Here is my config.lua, as an example:
[lua]application =
{
content =
{
width = 320,
height = 480,
scale = “zoomEven”,

imageSuffix =
{
["@2x"] = 2,
},
},
}[/lua]

Then, for example, I created a new, high resolution, version of header_image.png as header_image@2x.png.

Then, I changed this:
[lua]headerImg = display.newImage(“header_image.png”, x, y)[/lua]

To this:
[lua]headerImg = display.newImageRect(“header_image.png”, width, height)
headerImg.x = x
headerImg.y = y[/lua]

Hopefully something there helps you realize where your issue is. [import]uid: 4621 topic_id: 1361 reply_id: 5923[/import]

Unfortunately nope. I did everything you wrote except that I added fps = 60 in the config file. :frowning:
What could be wrong? Does this work with UI buttons? [import]uid: 7022 topic_id: 1361 reply_id: 5924[/import]

I’ve found the arcane! I wrote “@2” while my files are all “@2x”. :stuck_out_tongue:
Works great now but still not for UI. I may have a solution to get Dynamic Scaling working with UI elements. Give me ten minutes. :smiley: [import]uid: 7022 topic_id: 1361 reply_id: 5925[/import]

I GOT THE UI LIBRARY WORKING WITH DYNAMIC SCALING!!! YEAH!!! :smiley:

I’m writing an example code to show you how it works now. :wink: [import]uid: 7022 topic_id: 1361 reply_id: 5928[/import]

https://developer.anscamobile.com/code/ui-library

Here it is. Be sure to edit all your buttons as showed in the main.lua file. :smiley:
Ansca, can you include this in your future release examples? [import]uid: 7022 topic_id: 1361 reply_id: 5930[/import]

@Alwayk: Thanks for that! As well as everyone else who contributed to figuring this out. I’m getting a new iTouch 4 hopefully by the end of the week so this thread will definitely come in handy.

@Ansca: I second Alwayk in requesting an updated lua with that code (or other code with similar functionality) gets added to the ui.lua in the next release. [import]uid: 7849 topic_id: 1361 reply_id: 5934[/import]

So, anyone figured out how to use movieclip or spritesheet (would be better) with this?
I changed the movieclip.lua to use display.newImageRect and to use two values for width and height that you have to tell him when called, but I prefer spritesheet.
I haven’t figure out how to change the animation velocity with movieclip, nor how I can loop it going back and forth like the -2 in sprite :stuck_out_tongue: [import]uid: 8486 topic_id: 1361 reply_id: 5942[/import]

Just checked a little bit more, I really like to use this with spritesheet.
I modified the movieclip.lua to simply use display.newImageRect (basically I use value = display.newImageRect ({“image.png”}, width, height), I added the “Rect” part in the movieclip.lua and two other value for the starting function, width and height), but spritesheet would be soooo much better for me.
I do not even know where to look to find the sprite.lua file and try to modify that one, what a noob :'D
If there’s another way, please tell me, maybe I’m missing something :slight_smile: [import]uid: 8486 topic_id: 1361 reply_id: 5961[/import]

The “movieclip” library is a pure-Lua library using display.newImage(), so it’s quite possible to do a version that uses display.newImageRect() instead.

The thing to keep in mind is that 2x image files use FOUR times the texture data (or more), so you can burn through texture memory much more quickly. Therefore, I think this would be useful as an optional feature, but it wouldn’t be a good idea to make this mandatory.

Regarding the “sprite” library, it’s one of the “built-in” libraries, which means that it’s a Lua API to native C++ code, so there isn’t a “sprite.lua” file, and it doesn’t use display.newImage(). Using the “require” command for the built-in libraries simply means that the relevant native code is loaded at runtime. That’s why you can’t find the file :slight_smile:

So: is it possible to have multi-resolution sprite sheets? That would require a modification to our sprite-sheet code, but the answer is “yes, in some cases”.

The standard idea of a sprite-sheet is that you allocate the largest possible image area in device memory, and then pack sprite data onto it, using a lot of reference coordinates to pull data chunks from the sheet. Therefore, you can’t just double the sheet, since it may already be at “maximum size” for the device.

However, there are specific hardware combinations where this could be useful. One example is that you could do a 1024x1024 sprite sheet on iPhone3GS, and a “2x” 2048x2048 sprite sheet on iPhone4 and iPad. That should actually work pretty well – although, to be clear, this won’t work today, since it’s a code modification on our end. Also, results on Android may be mixed, since their hardware specs are all over the place; I don’t have a comprehensive list here, but I don’t think they universally support 2048 x 2048 textures in their current high-res devices.

The tradeoff with the above is, again, that you’d be using 4x the memory to get 2x the resolution. So if you try and do a sprite-intensive game entirely at “Retina Display” resolution, the amount of graphics you can use at one time will be reduced. But this is a basic limitation of mobile graphics hardware, and all developers have to deal with this, so I agree that it would be preferable for us to give our developers the choice either way.
[import]uid: 3007 topic_id: 1361 reply_id: 5969[/import]

As a simple alternative to all of the above, setting width = 640, height = 960 and scale=“zoomEven” or “letterbox” should look great on iPhone 4, and then scale down automatically for previous iPhones. For example, the latest “SimplePool_iPad” actually works fine on iPhone and Android, scaled down from the iPad size. It’s just a bit hard to play on smaller screens :slight_smile:

In the above 640x960 case, you need to work within the coordinates of your base content, so your contentWidth will return 640 (not 320) on all devices, and those are the coordinates you should program with. This is by design, though – the coordinate system should remain consistent, and not depend on the hardware.

The only gotcha is that you need to add the “true” flag in display.newImage() for any image over 512 pixels, or you’ll trigger the auto-downscale safety feature on the older iPhones. I keep forgetting this one myself.

Regarding icon files, we’ve just put 114x114 “Icon.png” files in all the sample code for the upcoming release, and this size seems to work perfectly well on iPhone, iPhone 4 and iPad – it automatically renders down to the correct resolution on each device, and looks great. So I’m not sure you need to ship multiple icon versions, although I believe that will also work (using Apple’s naming patterns). [import]uid: 3007 topic_id: 1361 reply_id: 5971[/import]

Thanks Evan!

Do you have a timeframe for the sprite sheet compatibility for the Dynamic Image Resolution feature?

[import]uid: 8194 topic_id: 1361 reply_id: 5974[/import]