Sup guys, hope youre doing great! <3
... sorry to bother here :v BUT
I have a question.
You know the 'Ball&Ground'(Box2d) Tutorial?.
How do you change the ball for an animated object?. Its the walk.love thing attached.
I can't think on anything Im blank after 32 hours not sleeping
This is what im using:
http://www.love2d.org/wiki/Tutorial:Physics
Hi :D - How can I add textures to a 'body'?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
-
- Prole
- Posts: 2
- Joined: Wed Apr 16, 2014 5:39 am
Hi :D - How can I add textures to a 'body'?
- Attachments
-
- walk.love
- Thats the walk animation I would like to use instead of the red ball :|
- (5.14 KiB) Downloaded 120 times
- Ranguna259
- Party member
- Posts: 911
- Joined: Tue Jun 18, 2013 10:58 pm
- Location: I'm right next to you
Re: Hi :D - How can I add textures to a 'body'?
All you need to do is to draw an image on top of the body, you can't actually "apply" a texture to it.
Load your image:
Create your circle body (as explained in the tutorial):
Draw the image using the circle coordinates in love.draw():
Done, if there's anything you don't undertand just say and I'll try to explain.
Load your image:
Code: Select all
image = love.graphics.newImage('image.png')
Code: Select all
objects.ball = {}
objects.ball.body = love.physics.newBody(world, 650/2, 650/2, "dynamic") --place the body in the center of the world and make it dynamic, so it can move around
objects.ball.shape = love.physics.newCircleShape( 20) --the ball's shape has a radius of 20
objects.ball.fixture = love.physics.newFixture(objects.ball.body, objects.ball.shape, 1) -- Attach fixture to body and give it a density of 1.
objects.ball.fixture:setRestitution(0.9) --let the ball bounce
Code: Select all
love.graphics.draw(image, objects.ball.body:getX(), objects.ball.body:getY(),0 ,1 ,1 , objects.ball.body:getRadius()/2, objects.ball.body:getRadius()/2)
-
- Prole
- Posts: 2
- Joined: Wed Apr 16, 2014 5:39 am
Re: Hi :D - How can I add textures to a 'body'?
for some reason the first script i made stoped working... ... ... ... dunno how :l
.. so i started from scartch and;
OMG ! THANKS YOUUUUUUU <3 !
It worked. <3
now its time to get it to move
.. so i started from scartch and;
OMG ! THANKS YOUUUUUUU <3 !
It worked. <3
now its time to get it to move
Who is online
Users browsing this forum: Bing [Bot] and 3 guests