love.draw error?

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
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

love.draw error?

Post by larz »

Code: Select all

local run={};
do
	run.draw=love.draw;
	
	function run.draw()
		love.graphics.print("Hello.",100,100);
	end
end
Why this doesn't works?
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: love.draw error?

Post by Ref »

Code: Select all

function love.draw()
   love.graphics.print('Hello!',100,100)
end
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

Re: love.draw error?

Post by larz »

Can't i reffer to it by run.draw?
larz
Prole
Posts: 9
Joined: Fri Jan 08, 2016 2:57 pm

Re: love.draw error?

Post by larz »

Someone?
User avatar
veethree
Inner party member
Posts: 877
Joined: Sat Dec 10, 2011 7:18 pm

Re: love.draw error?

Post by veethree »

Is there a reason why you don't want to just use love.draw?

I think if you want to call it run.draw you would have to use a custom love.run function.
User avatar
slime
Solid Snayke
Posts: 3163
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.draw error?

Post by slime »

Code: Select all

local run = {}

function run.draw()
    love.graphics.print("hi")
end

love.draw = run.draw
(Not that it's particularly useful to do something like that...)
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: love.draw error?

Post by Ref »

But that doesn't print to the screen (at 100,100) but prints 'Hi 100 100".
User avatar
Jasoco
Inner party member
Posts: 3726
Joined: Mon Jun 22, 2009 9:35 am
Location: Pennsylvania, USA
Contact:

Re: love.draw error?

Post by Jasoco »

You're overthinking it. Use this as a starting point:

Code: Select all

function love.load()
    --Put stuff here that needs to be loaded once like creating images or fonts
end

function love.update(dt)
    --Update things here using dt as a delta (Amount per second)
end

function love.draw()
    love.graphics.print("Hello.", 100, 100)
end
While you can put functions in other functions, it won't do anything unless you actually call it.

And look at the Wiki.
PGUp
Party member
Posts: 105
Joined: Fri Apr 21, 2017 9:17 am

Re: love.draw error?

Post by PGUp »

Why do you need to make it very complex..
-
Post Reply

Who is online

Users browsing this forum: No registered users and 4 guests