I have tried, but it does not work for me, i am EXTREMELY new to LOVE and i only know the basics of lua programming. So, what i did was i took the a couple tutorials on the wiki, and one of them was the physics one, and to test out how our character will look in the actual game, i put the callback command for making the .png image into the ball. This is the exact script:
function love.load()
world = love.physics.newWorld(0, 0, 650, 650)
world:setMeter(64)
objects = {}
objects.ground = {}
objects.ground.body = love.physics.newBody(world, 650/2, 625, 0, 0)
objects.ground.shape = love.physics.newRectangleShape(objects.ground.body, 0, 0, 650, 50, 0)
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 650/2, 650/2, 15, 0)
objects.ball.shape = love.physics.newCircleShape(objects.ball.body, 0, 0, 20)
love.graphics.setBackgroundColor(104, 136, 248)
love.graphics.setMode(650, 650, false, true, 0)
end
function love.update(dt)
world:update(dt)
if love.keyboard.isDown("right") then
objects.ball.body:applyForce(400, 0)
elseif love.keyboard.isDown("left") then
objects.ball.body:applyForce(-400, 0)
elseif love.keyboard.isDown("up") then
objects.ball.body:setY(650/2)
end
end
function love.draw()
love.graphics.setColor(72, 160, 14)
love.graphics.polygon("fill", objects.ground.shape:getPoints())
love.graphics.setColor(193, 47, 14)
love.graphics.circle(objects.ball.body:function love.load()
image = love.graphics.newImage("template.png")
local f = love.graphics.newFont(12)
love.graphics.setFont(f)
love.graphics.setColor(0,0,0,255)
love.graphics.setBackgroundColor(255,255,255)
end)
end
When i put the folder into love, it gives me this error:
<name> Expected near function on line 29
Please help and correct me, and thank you in advance!
Question and problem: How do you put in a .png image?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Question and problem: How do you put in a .png image?
The problem is that I don't think you can load new variables like you are trying to do. Could you please provide a .love?
EDIT: And also, instead of using physics, you should just do something like:
That should be all you need.
EDIT: And also, instead of using physics, you should just do something like:
Code: Select all
function love.load()
guy=love.graphics.newImage('template.png')
guyx=20
guyy=20
guyspeed=20
end
function love.update(dt)
if guyy<500 then--"gravity"
guyy=guyy-2
end
end
function love.draw()
love.graphics.draw(guy,guyx,guyy)
end
Last edited by jradich on Wed Mar 14, 2012 10:31 pm, edited 1 time in total.
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
- nevon
- Commander of the Circuloids
- Posts: 938
- Joined: Thu Feb 14, 2008 8:25 pm
- Location: Stockholm, Sweden
- Contact:
Re: Question and problem: How do you put in a .png image?
This part is completely messed up. I don't even know what's going on.
Code: Select all
function love.draw()
love.graphics.setColor(72, 160, 14)
love.graphics.polygon("fill", objects.ground.shape:getPoints())
love.graphics.setColor(193, 47, 14)
love.graphics.circle(objects.ball.body:function love.load()
image = love.graphics.newImage("template.png")
local f = love.graphics.newFont(12)
love.graphics.setFont(f)
love.graphics.setColor(0,0,0,255)
love.graphics.setBackgroundColor(255,255,255)
end)
end
Re: Question and problem: How do you put in a .png image?
dear qwetroop,
check ma edit.
love,
jradich
check ma edit.
love,
jradich
Losing a friend's trust is the fastest way to lose a friend, forever. FOREVER!
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Question and problem: How do you put in a .png image?
Oh, and for the future, please use the Code tags. It makes your post actually readable and preserves spaces and tabulation.
Code: Select all
function awesome()
print("Radical!")
end
Re: Question and problem: How do you put in a .png image?
Well, for the edit, his gravity is backwards xD but yeah, that works! thank you! and from now on, i will do the code tags, thanks!
Who is online
Users browsing this forum: Ahrefs [Bot] and 5 guests