I am helping @Chell on the portal project, and have run into an issue. I want to make a Sprite correspond to a physics body. How could I do this?
Thanks @Ignatz totally forgot about your blog!
But how can I make a Sprite follow this?
@Kai Here’s an example.
function setup() e1=physics.body(EDGE,vec2(0,0),vec2(WIDTH,0)) c1=physics.body(CIRCLE,50) c1.x=250 c1.y=900 c1.restitution=1 end function draw() background(0) sprite("Planet Cute:Character Horn Girl",c1.x,c1.y) end
Oh ok thanks @dave1707
Create a class for your object.
I think you know how to create a physic body, right?
self.body = physics.body(CIRCLE, 64) -- circle figure 64px radius self.body.x = x self.body.y = y
pushMatrix() -- save current matrix before editing translate(self.body.x,self.body.y) -- move the offset to self body position rotate(self.body.angle) -- angle of body to rotate the sprite sprite("SpaceCute:Star",0,0,128) -- draw sprite with same size as body popMatrix() -- restore the saved matrix