Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Using Image As Background (Not displaying at fullest dimensions)

edited October 2019 in Questions Posts: 46

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:

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:


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)


  • edited October 2019 Posts: 1,768

    @tactfulgamer - try:

    sprite(spritename,screen centre X, screen centre Y, WIDTH,HEIGHT)
  • Posts: 790

    @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.

Sign In or Register to comment.