scene/mainmenu: use a canvas for the repeating background
This commit is contained in:
parent
e6355533a4
commit
ef73ffc0f3
|
@ -10,7 +10,7 @@ local bannerAnim = 0
|
|||
function MainMenu:new()
|
||||
MainMenu.super.new(self)
|
||||
|
||||
assets:setBackground( "back" )
|
||||
self:createBackground("assets/backgrounds/back.png")
|
||||
menus:reset()
|
||||
assets:clearFonts()
|
||||
assets:addFont("small", "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~ ", 1)
|
||||
|
@ -35,6 +35,21 @@ function MainMenu:new()
|
|||
self:register()
|
||||
end
|
||||
|
||||
function MainMenu:createBackground( filename )
|
||||
local backAsset = love.graphics.newImage( filename )
|
||||
self.background = love.graphics.newCanvas(424, 240)
|
||||
love.graphics.setCanvas( self.background )
|
||||
local w, h = backAsset:getDimensions()
|
||||
|
||||
for i=1, math.ceil(424 / w) do
|
||||
for j=1,math.ceil(240/ h) do
|
||||
love.graphics.draw(backAsset, (i-1)*w, (j-1)*h, 0, 1, 1)
|
||||
end
|
||||
end
|
||||
|
||||
love.graphics.setCanvas( )
|
||||
end
|
||||
|
||||
function MainMenu:update(dt)
|
||||
MainMenu.super.update(self, dt)
|
||||
lovebird.update()
|
||||
|
@ -55,7 +70,7 @@ function MainMenu:mousepressed( x, y, button, istouch )
|
|||
end
|
||||
|
||||
function MainMenu:draw()
|
||||
assets:drawBackground()
|
||||
love.graphics.draw(self.background)
|
||||
assets.sprites["emblem"]:draw(1, 240, 272/2-32, 0, 1, 1, 330/2, 192/2)
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue