I’m looking to create a large playing area, bigger than the screen, but only want to display a portion of it. The following is my attempt at this, but it appears to be clipping the image to the screen size. Any suggestions as to where I’m going wrong gratefully received. I’ve also added a couple of tests to print sprites, one inside the original screen dimensions, which works, and one outside, which doesn’t
-- BackgroundTest
displayMode(FULLSCREEN)
-- Use this function to perform your initial setup
function setup()
globalx=0
scroll=1
bg=mesh()
bgw=2048
bgh=768
bgimg=image(bgw,bgh)
bg.texture=bgimg
block=25
setContext(bgimg)
for i=1,15 do
sprite("Cargo Bot:Crate Red 2",800+(block*i),200+3*i,block,block)
end
setContext()
end
-- This function gets called once every frame
function draw()
-- This sets a dark background color
bg:clear()
background(40, 40, 50)
local bgid=bg:addRect(WIDTH/2,HEIGHT/2,1024,768)
bg:setRectTex(bgid,globalx/2048,0,0.5,1)
bg:draw()
globalx = globalx + scroll
if globalx>1024 or globalx<0 then
scroll=scroll*-1
setContext(bgimg)
sprite("Cargo Bot:Hints Button",200,200,100,100)
sprite("Cargo Bot:Hints Button",1400,400,100,100)
setContext()
end
end