Howdy, Stranger!

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

Image tiling for background.

edited October 2014 in General Posts: 300

Hi all

Sorry for all of the questions.

If I have a grass art tile that is approx 64x64, and I want to tile it to fit the iPad screen as a background and save the background as a variable. Is there an easy way to do this? Or am I better off doing it in a dedicated art program?

Seems like it wound be a pain and memory hog to place each tile individually.


  • Jmv38Jmv38 Mod
    edited October 2014 Posts: 3,295
  • dave1707dave1707 Mod
    Posts: 7,612

    @Crumable You can use setContext. Here's an example. The grass tile I'm using here is 70x70.

    displayMode(FULLSCREEN) function setup() spriteMode(CORNER) img=readImage("Platformer Art:Block Grass") img1=image(WIDTH,HEIGHT) w=WIDTH/img.width h=HEIGHT/img.height setContext(img1) for x=0,w do for y=0,h do sprite(img,x*img.width,y*img.height) end end setContext() end function draw() background(40, 40, 50) sprite(img1,0,0) end
  • IgnatzIgnatz Mod
    Posts: 5,396

    @Crumble - in this case, I would use dave's method. My approach is best for 3D or when you have irregularly sized objects, or very large areas to tile.

  • Posts: 300

    Awesome! I learn so much from you guys! Thanks much

Sign In or Register to comment.