I followed the physics tutorial: http://love2d.org/wiki/Tutorial:Physics
and i want to change the red circle to a smiley face. the coding for physics is different than the hampser ball tutorial coding, so i can't do love.graphics.newImage! someone please tell me how to do this.
thanks.
How do i load an image onto a player with physics?
- Taehl
- Dreaming in associative arrays
- Posts: 1025
- Joined: Mon Jan 11, 2010 5:07 am
- Location: CA, USA
- Contact:
Re: How do i load an image onto a player with physics?
You do still use love.graphics.newImage, just like the hampster ball tutorial. The only difference is, you have to draw it at the coordinates of the physics body. So the code would be like this:
Code: Select all
love.graphics.love.graphics.draw( hamster, objects.ball.body:getX(), objects.ball.body:getY() )
Earliest Love2D supporter who can't Love anymore. Let me disable pixel shaders if I don't use them, dammit!
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Lenovo Thinkpad X60 Tablet, built like a tank. But not fancy enough for Love2D 0.10.0+.
Re: How do i load an image onto a player with physics?
ohhhh ok thanks. that goes under function love.draw() right?Taehl wrote:You do still use love.graphics.newImage, just like the hampster ball tutorial. The only difference is, you have to draw it at the coordinates of the physics body. So the code would be like this:Code: Select all
love.graphics.love.graphics.draw( hamster, objects.ball.body:getX(), objects.ball.body:getY() )
- slime
- Solid Snayke
- Posts: 3170
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: How do i load an image onto a player with physics?
Taehl wrote:You do still use love.graphics.newImage, just like the hampster ball tutorial. The only difference is, you have to draw it at the coordinates of the physics body. So the code would be like this:Code: Select all
love.graphics.love.graphics.draw( hamster, objects.ball.body:getX(), objects.ball.body:getY() )
Code: Select all
local b = objects.ball.body
love.graphics.draw(hamster, b:getX(), b:getY(), b:getAngle(), 1, 1, hamster:getWidth()/2, hamster:getHeight()/2)
Re: How do i load an image onto a player with physics?
I tried that and got:slime wrote:Taehl wrote:You do still use love.graphics.newImage, just like the hampster ball tutorial. The only difference is, you have to draw it at the coordinates of the physics body. So the code would be like this:Code: Select all
love.graphics.love.graphics.draw( hamster, objects.ball.body:getX(), objects.ball.body:getY() )
Code: Select all
local b = objects.ball.body love.graphics.draw(hamster, b:getX(), b:getY(), b:getAngle(), 1, 1, hamster:getWidth()/2, hamster:getHeight()/2)
Error
main.lua:49: attempt to index global 'object'(a nil value)
help?
- TechnoCat
- Inner party member
- Posts: 1612
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: How do i load an image onto a player with physics?
object ~= objectsworldaway wrote:I tried that and got:slime wrote:Code: Select all
local b = objects.ball.body love.graphics.draw(hamster, b:getX(), b:getY(), b:getAngle(), 1, 1, hamster:getWidth()/2, hamster:getHeight()/2)
Error
main.lua:49: attempt to index global 'object'(a nil value)
help?
Who is online
Users browsing this forum: Google [Bot] and 4 guests