Canvas Help [SOLVED]

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Lolocks
Prole
Posts: 12
Joined: Tue Jul 15, 2014 3:06 pm

Canvas Help [SOLVED]

Post by Lolocks »

Some I'm starting to make a new game and I've come across a bug that should really be repaired.

Short background story: I'm using the canvas thingy to make a startup menu with different pages.

Anyways, for some reason, when I set the canvas after converting into one, the canvas is blank. I asked a friend about this and he said he got that problem too. The only way he got around it was removing some code from the canvas. Problem is, I don't want to remove some code and make everything unorganized and stuff. Is there a way to get around this bug?

Expected: The canvas is drawn exactly how it was coded
Problem: The canvas appears blank when drawn

Code:

Code: Select all

function love.load()
	--main variables
	flux = require "flux" --flux.to(obj, time, { x = num, y = num})
	Quickie = require "Quickie"
	TitleFont = love.graphics.newFont("/fonts/FaceYourFears.ttf", 45)
	--Canvas
	MainMenuCanvas = love.graphics.newCanvas()
	HowToPlayCanvas = love.graphics.newCanvas()
	CreditsCanvas = love.graphics.newCanvas()
	--MainMenu Canvas
	love.graphics.setCanvas(MainMenuCanvas)
		MainMenuCanvas:clear()
		love.graphics.setFont(TitleFont)
		love.graphics.setColor(255, 0, 0)
		love.graphics.print(_G.GameTitle, (TitleFont:getWidth(_G.GameTitle)/2), 10)
end

function love.update(dt)
	--
end

function love.draw()
	love.graphics.draw(MainMenuCanvas)
end
EDIT: Added .love file
Attachments
Game.love
(357.03 KiB) Downloaded 105 times
Last edited by Lolocks on Sat Jul 19, 2014 5:31 pm, edited 1 time in total.
User avatar
MadByte
Party member
Posts: 533
Joined: Fri May 03, 2013 6:42 pm
Location: Braunschweig, Germany

Re: Canvas Help

Post by MadByte »

When setting a canvas with love.graphics.setCanvas(canvas) you need to call the function a second time to "finish" your canvas object.
Therefor you simply have to put love.graphics.setCanvas() without an argument behind your canvas code.

Code: Select all

   --MainMenu Canvas
   love.graphics.setCanvas(MainMenuCanvas)
   MainMenuCanvas:clear()
   love.graphics.setFont(TitleFont)
   love.graphics.setColor(255, 0, 0)
   love.graphics.print(_G.GameTitle, (TitleFont:getWidth(_G.GameTitle)/2), 10)
   love.graphics.setCanvas() -- new line
Lolocks
Prole
Posts: 12
Joined: Tue Jul 15, 2014 3:06 pm

Re: Canvas Help

Post by Lolocks »

MadByte wrote:When setting a canvas with love.graphics.setCanvas(canvas) you need to call the function a second time to "finish" your canvas object.
Therefor you simply have to put love.graphics.setCanvas() without an argument behind your canvas code.

Code: Select all

   --MainMenu Canvas
   love.graphics.setCanvas(MainMenuCanvas)
   MainMenuCanvas:clear()
   love.graphics.setFont(TitleFont)
   love.graphics.setColor(255, 0, 0)
   love.graphics.print(_G.GameTitle, (TitleFont:getWidth(_G.GameTitle)/2), 10)
   love.graphics.setCanvas() -- new line
Thanks!
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests