@2x with display.newImage? (Probably making a simple mistake)

window.arrow = display.newImage(window, "npc/chatarrow.png") -- nope window.arrow = display.newImage(window, "npc/chatarrow.png", true) -- nope window.arrow = display.newImageRect(window, "npc/chatarrow.png", 24, 12) -- nope

I have chatarrow.png and chatarrow@2x.png in the same spot. config.lua has the right suffix setup - I know because Lime is correctly using the @2x tile set in the same scene! - but for the life of me I just can’t get the @2x version to show up…is there a solution apart from using image sheets? [import]uid: 41884 topic_id: 29062 reply_id: 329062[/import]

Noob question here, whats up with “window” before the filename string? [import]uid: 164950 topic_id: 29062 reply_id: 116941[/import]

You can specify a display group before creating images. (This works for text, too.)

[code]local image = display.newImage(group, “filename.png”) – short

local image = display.newImage(“filename.png”)
group:insert(image) – long[/code] [import]uid: 41884 topic_id: 29062 reply_id: 116947[/import]

It should work (no idea about Lime though, haven’t used it). Maybe there’s something wrong with config.lua? Double check yours with mine:

[lua]application = {
content = {
width = 320,
height = 480,
scale = “zoomEven”,
audioPlayFrequency=“44100”,
fps = 30,

imageSuffix = {
["@2x"] = 2,
["@4x"] = 4,
}
}
}[/lua] [import]uid: 144908 topic_id: 29062 reply_id: 116957[/import]

I’m using almost an identical config.lua, actually. (Just don’t have a @4x or frequency set.) Decided to try fresh and see what happens.

[code]-- main.lua
– chatarrow.png and chatarrow@2x.png exist in the same folder as main.lua

– Using display.newImage()
local test = display.newImage(“chatarrow.png”, 100, 240)

– Using imageSheets
local options = { width=24, height=16, numFrames=1, sheetContentWidth=24, sheetContentHeight=16 }
local sheet = graphics.newImageSheet(“chatarrow.png”, options)
local test2 = (sheet, 1)
test2.x, test2.y = 200, 240
[/code]

-- config.lua application = { content = { width = 320, height = 480, fps = 60, imageSuffix = { ["@2x"] = 2, }, }, }

Using that code…

test1 : always uses the normal version of the image, regardless of platform or zoom level selected in the simulator.

test2 : uses the normal version in 3G view but switches to the 2x version in iPhone 4 view. Maintains the 2x art regardless of zoom level.

Is this a bug? Or is display.newImage() just not using suffixes right now? (Build 862) [import]uid: 41884 topic_id: 29062 reply_id: 117022[/import]

I don’t think display.newImage has ever been retina-aware, you have to use display.newImageRect. You said in your original post that you tried newImageRect so that is a strange one if it didn’t work, has always worked for me… [import]uid: 93133 topic_id: 29062 reply_id: 117024[/import]

Alright, yeah, I’m sure I tried Rect last night, but maybe I forgot to set the height/width? Just tried that now and it seems to work. So this thread is now considered resolved. Thanks :slight_smile:

From a practicality standpoint I wonder if Corona will try to merge the two functions (which otherwise seem to be basically display.newText vs. display.newRetinaText) but it’s my fault for not realizing newImage still had no suffix support… [import]uid: 41884 topic_id: 29062 reply_id: 117031[/import]