Position of an image using newImageRect

Im not seeing how to position an image when using newImageRect. I tried  putting x and y co-ordinates beneath it, and tried adding it to a group, but I got an error. This is what I was entering,

local intro display.newImageRect( “intro_image.jpg”, 300, 334)

I keep getting the image in the top left corner, which Im guessing is to do perhaps with display.getCurrentStage())  but am not sure how to proceed.

The display.newImageRect() is expecting “width” and “height”, not “x” and “y”.  You set those manually after the fact:

local someImage = display.newImageRect(“someimage.png”, 100, 120) – assuming a 100px wide, 120px high image

someImage.x = 300  – position 300 points from the left edge of the screen

someImage.y = 334  – position 300 points from the top edge of the screen.

Rob

I think I see now. I didnt refer to the correct file extension for the image. Corono didnt mine when I just had,

local someImage = display.newImageRect(“someimage.png”, 100, 120) -

But once I put in as well,

someImage.x = 300  – position 300 points from the left edge of the screen

someImage.y = 334  – position 300 points from the top edge of the screen.

It errored.

So, duh.

Thanks :wink:

The display.newImageRect() is expecting “width” and “height”, not “x” and “y”.  You set those manually after the fact:

local someImage = display.newImageRect(“someimage.png”, 100, 120) – assuming a 100px wide, 120px high image

someImage.x = 300  – position 300 points from the left edge of the screen

someImage.y = 334  – position 300 points from the top edge of the screen.

Rob

I think I see now. I didnt refer to the correct file extension for the image. Corono didnt mine when I just had,

local someImage = display.newImageRect(“someimage.png”, 100, 120) -

But once I put in as well,

someImage.x = 300  – position 300 points from the left edge of the screen

someImage.y = 334  – position 300 points from the top edge of the screen.

It errored.

So, duh.

Thanks :wink: