Hello. I’m trying to make a rectangle be filled by an endlessly repeating 32x32 texture. When I do something like:
display.setDefault( "textureWrapX", "repeat" ) display.setDefault( "textureWrapY", "repeat" ) local x,y = display.contentCenterX, display.contentCenterY local o = display.newRect( x, y, display.contentWidth, display.contentHeight ) o.fill = { type="image", filename="images/ocean\_single.png" } o.fill.scaleX = 0.1 o.fill.scaleY = 0.1
the results are perfect (see attached image).
However, I have no way to animate this. I learned that I would be able to do the same thing with a sprite sheet. looking through a few forum posts, the following is the closest I was able to come up with:
local oceanSheetCoords = require("lua-sheets.ocean\_1") local oceanSheet = graphics.newImageSheet("images/ocean\_1.png", oceanSheetCoords:getSheet()) local paint = { type = "image", sheet = oceanSheet, frame = 1 }
local function setFrame( obj, paint, frame ) paint.frame = frame obj.fill = paint end
display.setDefault( “textureWrapX”, “repeat” )
display.setDefault( “textureWrapY”, “repeat” )
local x,y = display.contentCenterX, display.contentCenterY local o = display.newRect( x, y, display.contentWidth, display.contentHeight ) o.fill = paint o.fill.scaleX = 0.1 o.fill.scaleY = 0.1 – for changing the frame of the sprite – setFrame( o, paint, 1 )
Now the setFrame() function roaminggamer suggested in another post works to switch the frame will satisfy what I need to make a seamless animation. The big issue is that I can’t get the image to look anything like it looked in the first code block! Either something is preventing, or prohibiting, the fill.scaleX and fill.scaleY to repeat the texture like in the first code block.
I’m attaching screenshots taken of the results from each code block. Thanks for any help that comes my way 