Using Image As Background (Not displaying at fullest dimensions)

Right when I find a VERY cool Lua tutorial video lessons to teach me, here comes Codea with it’s limited ass (stopping me from learning)!

Forcing me to find other ways to learn. So back I go to unstructured learning - which seems to be what this community has to offer. Unstructured videos - and unstructured crappy ways of learning that doesn’t stick.

The tutorial I am now following is this one -flappy bird game:
https://youtu.be/Aj43kuCTT84

I tried adding the image attached below as my background. However, it’s not displaying at it’s correct dimensions, which I think are 768x1024 - either way, the background is too small. It’s supposed to fit the entire screen of my ipad pro 10.5

I tried adjusting the following values - to increase it’s size:

sprite("Documents:CityBG",w50,h50,w50)

The above values in w,h,w are way to small, I cannot change them to higher values. For example, if I change the last w(the one to the far right) to 100 - I get following error message on the console:

Main: 12: bad argument #4 to ‘sprite’ (number expected, got nil)
stack traceback:
[C]: in function ‘sprite’
Main: 12: in function ‘draw’

Basically, I just want the image to take up the entire background. That is all.
How do I go about this? Thank you.

Tried searching all of these - none of these codes work for me (or they don’t explain how/where to place them - I just followed what they showed)

https://codea.io/talk/discussion/1909/background-image

https://codea.io/talk/discussion/2148/how-to-use-background-images-as-background

https://codea.io/talk/discussion/5086/background-sprite-image-size-question

https://codea.io/talk/discussion/926/image-as-a-background

@tactfulgamer - try:


sprite(spritename,screen centre X, screen centre Y, WIDTH,HEIGHT)

@tactfulgamer The second link you provided does exactly what you want it do. In particular, the commented out line shows how to do it - in your case:

sprite("Documents: CityBG", WIDTH/2, HEIGHT/2, WIDTH, HEIGHT)

WIDTH is a special variable which returns the width of the screen for the current device

HEIGHT is a special variable which returns the height of the screen for the current device

Looking at the tutorial video, this person loads a set up function which provide some sort of lookup for w50, h50, h10 etc. It looks like you haven’t included this which is why the error is being shown.