Jump to content

[TOPIC: topicViewTemplate]
[GLOBAL: userSmallPhoto]
Photo

iPhone 4 problem!
Started by Alwayk Jul 05 2010 08:48 PM

- - - - -
98 replies to this topic
[TOPIC CONTROLS]
Page 2 of 4 1 2 3 4
This topic has been archived. This means that you cannot reply to this topic.
[/TOPIC CONTROLS]
[modOptionsDropdown]
[/modOptionsDropdown]
[reputationFilter]
[TOPIC: post.html]
#26

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

Again, any news?
uid: 7022 topic_id: 1361 reply_id: 5902


[TOPIC: post.html]
#27

Tom

[GLOBAL: userInfoPane.html]
Tom
  • Moderator

  • 1,480 posts
  • Corona Staff

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
uid: 7559 topic_id: 1361 reply_id: 5906


[TOPIC: post.html]
#28

LiveToCollect

[GLOBAL: userInfoPane.html]
LiveToCollect
  • Enthusiast

  • 53 posts
  • Guests

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?
uid: 4621 topic_id: 1361 reply_id: 5909


[TOPIC: post.html]
#29

H4ch1

[GLOBAL: userInfoPane.html]
H4ch1
  • Enthusiast

  • 74 posts
  • Corona SDK

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


[TOPIC: post.html]
#30

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

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


[TOPIC: post.html]
#31

LiveToCollect

[GLOBAL: userInfoPane.html]
LiveToCollect
  • Enthusiast

  • 53 posts
  • Guests

@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:
application ={     content =     {          width = 320,          height = 480,          scale = "zoomEven",				          imageSuffix =          {               ["@2x"] = 2,          },     },}


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

Then, I changed this:
headerImg = display.newImage("header_image.png", x, y)


To this:
headerImg   = display.newImageRect("header_image.png", width, height)headerImg.x = xheaderImg.y = y


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


[TOPIC: post.html]
#32

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

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


[TOPIC: post.html]
#33

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

I've found the arcane! I wrote "@2" while my files are all "@2x". :P
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. :D
uid: 7022 topic_id: 1361 reply_id: 5925


[TOPIC: post.html]
#34

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

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

I'm writing an example code to show you how it works now. ;)
uid: 7022 topic_id: 1361 reply_id: 5928


[TOPIC: post.html]
#35

Alwayk

[GLOBAL: userInfoPane.html]
Alwayk
  • Enthusiast

  • 71 posts
  • Guests

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

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


[TOPIC: post.html]
#36

jonbeebe

[GLOBAL: userInfoPane.html]
jonbeebe
  • Contributor

  • 511 posts
  • Corona SDK

@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.
uid: 7849 topic_id: 1361 reply_id: 5934


[TOPIC: post.html]
#37

H4ch1

[GLOBAL: userInfoPane.html]
H4ch1
  • Enthusiast

  • 74 posts
  • Corona SDK

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 :P
uid: 8486 topic_id: 1361 reply_id: 5942


[TOPIC: post.html]
#38

H4ch1

[GLOBAL: userInfoPane.html]
H4ch1
  • Enthusiast

  • 74 posts
  • Corona SDK

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 :)
uid: 8486 topic_id: 1361 reply_id: 5961


[TOPIC: post.html]
#39

evank

[GLOBAL: userInfoPane.html]
evank
  • Contributor

  • 317 posts
  • Alumni

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 :)

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.
uid: 3007 topic_id: 1361 reply_id: 5969


[TOPIC: post.html]
#40

evank

[GLOBAL: userInfoPane.html]
evank
  • Contributor

  • 317 posts
  • Alumni

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 :)

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).
uid: 3007 topic_id: 1361 reply_id: 5971


[TOPIC: post.html]
#41

dknell

[GLOBAL: userInfoPane.html]
dknell
  • Contributor

  • 143 posts
  • Corona SDK

Thanks Evan!

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

uid: 8194 topic_id: 1361 reply_id: 5974


[TOPIC: post.html]
#42

jwwtaker

[GLOBAL: userInfoPane.html]
jwwtaker
  • Contributor

  • 204 posts
  • Corona SDK

How come for me, when i run in the simulator using a regular iphone the app looks perfect, but on iphone 4 everything is squished into the top left corner of the device. How can I stretch the app to look on on the iphone 4 also using the old coordinate system (since new version of corona only builds with 4.0 compatibility on iphone). This is the error I get when I try to use the sample build.settings used here that seemed to work for others.

This error happens both with an EMPTY build.settings file or the one i placed below

PANIC: unprotected error in call to Lua API (attempt to index a nil value)
logout

my build.settings

application =
{
     content =
     {
          width = 320,
          height = 480,
          scale = "zoomEven",
     },
}
uid: 6317 topic_id: 1361 reply_id: 7049


[TOPIC: post.html]
#43

Tom

[GLOBAL: userInfoPane.html]
Tom
  • Moderator

  • 1,480 posts
  • Corona Staff

Try putting the code in config.lua (not build.settings). You're confusing the Corona simulator :)

-Tom
uid: 7559 topic_id: 1361 reply_id: 7051


[TOPIC: post.html]
#44

MauMau

[GLOBAL: userInfoPane.html]
MauMau
  • Contributor

  • 123 posts
  • Corona SDK

Hm, as a complete Corona beginner, the scaling stuff discussion here is quite confusing :-(
What I would like is to provide only ONE set of graphics - in high resolution - (targetting iPhone 4 as default) which will all be scaled down by Corona automatically on a iPhone 3. I really would not want to include two complete sets of graphics in my binary since this would have a big impact on the file size. In my opinion, providing a high res set only and let it scale down automatically provides better visual quality than providing a low res set and let it scale up, doesn't it?

So to proof if I understood this correctly:

I can achieve this by saving a single set of images in high resolution to my project folder and using a config.lua as shown below. This will then scale down all my graphics to a smaller resolution if the game is running on a iPhone3, right?

application =
{
    content =
    {
        width = 640,
        height = 960,
        scale = "zoomEven",
     },
}
So, to break it down:
- I will design all my images in high res (targetting the iPhone 4 resolution)
- Specifiy the base resolution in my config.lua (640 x 960)
- Then I use the 640 x 960 coordinate system within my game code
- Corona does all the rest (scaling down on iPhone 3 etc.)
- And if I would like to EXCLUDE certain images from automatic scaling, I use the "@" naming convention. Those images are then NOT scaled, but loaded from a different file instead, without scaling.

Is this correct so far?
uid: 9644 topic_id: 1361 reply_id: 7168


[TOPIC: post.html]
#45

Tom

[GLOBAL: userInfoPane.html]
Tom
  • Moderator

  • 1,480 posts
  • Corona Staff

The scaling modes are used to scale up, not scale down. If you specify 620 x 960 in config.lua, it will not work on a 320 x 480 iphone.

If you want to target iphone4 and iphone3, you need to provide two sets of graphics if you want the high resolution graphics on the iphone4. Not all your graphics need to be high resolution -- only the ones that need the higher resolution images. The graphics made for the 320x480 format will scale up on the iPhone4.

If you want to target both platforms, you need to work in a 320x480 coordinate system.

-Tom
uid: 7559 topic_id: 1361 reply_id: 7181


[TOPIC: post.html]
#46

jonbeebe

[GLOBAL: userInfoPane.html]
jonbeebe
  • Contributor

  • 511 posts
  • Corona SDK

Between the documentation and this thread, I think the whole "how to" process got a little messy, so I created a 3-step tutorial and posted it to CoronaSDK.com.

--> http://ideveloper.kodingen.com/2010/retina-display-setup-in-3-easy-steps/

Hopefully that will help newcomers to this thread :-)
uid: 7849 topic_id: 1361 reply_id: 7297


[TOPIC: post.html]
#47

Tom

[GLOBAL: userInfoPane.html]
Tom
  • Moderator

  • 1,480 posts
  • Corona Staff

Jonathan,

Thanks for posting the detailed information and I'm sure it will be more helpful than trying to read this thread.

One correction I would like to make is to a statement you made in Step 2: "Obviously the width and height should be switched if your app uses landscape orientation."

The wide and height values specified in config.lua is the size of the screen your app was designed for. These values are always specified in portrait mode -- even if your app runs in landscape mode.

We are working hard to improve our own documentation and to provide better examples for all our APIs.

Thanks again for the great write-up.

-Tom
uid: 7559 topic_id: 1361 reply_id: 7298


[TOPIC: post.html]
#48

jonbeebe

[GLOBAL: userInfoPane.html]
jonbeebe
  • Contributor

  • 511 posts
  • Corona SDK

@Tom: That's news to me! Lol ... I'll go fix the post.
uid: 7849 topic_id: 1361 reply_id: 7299


[TOPIC: post.html]
#49

MauMau

[GLOBAL: userInfoPane.html]
MauMau
  • Contributor

  • 123 posts
  • Corona SDK

Thanks for the tutorial, jonbeebe, this was exactly what I was looking for! :-)

However, I hope that upcoming versions of Corona will support this by default (without changing any libs).

- One question regarding the changed libs: is this kind of a temporary "hack" or an official solution? Will my code also work in future Corona releases then or will I have to change it again when upgrading?

uid: 9644 topic_id: 1361 reply_id: 7309


[TOPIC: post.html]
#50

jonbeebe

[GLOBAL: userInfoPane.html]
jonbeebe
  • Contributor

  • 511 posts
  • Corona SDK

Unfortunately it's a temporary "hack" (changes to movieclip, ui, etc). When you upgrade your version of Corona, you should still have the same ui.lua and movieclip.lua file in your project folder.

If Ansca were to give us new ui.lua and movieclip.lua files, then I'm sure they would include the changes since retina display is here to stay, so I wouldn't worry about that too much--it would be in the release notes.
uid: 7849 topic_id: 1361 reply_id: 7313



[topic_controls]
Page 2 of 4 1 2 3 4
 
[/topic_controls]