It looks like you're new here. If you want to get involved, click one of these buttons!
local shard1 = Prop.new(self.pack, "shard.png", target.sprite:getX(), target.sprite:getY() - 96, 0.5, 0.5, mg) world:createRectangle(shard1, {type = "dynamic", isSensor = true}) shard1:setRotation(0) shard1:set("linearVelocityX", 5 * math.cos(math.random(360))) shard1:set("linearVelocityY", 5 * math.sin(math.random(360))) local shard2 = Prop.new(self.pack, "shard.png", target.sprite:getX(), target.sprite:getY() - 96, 0.5, 0.5, mg) world:createRectangle(shard2, {type = "dynamic", isSensor = true}) shard2:setRotation(90) shard2:set("linearVelocityX", 5 * math.cos(math.random(360))) shard2:set("linearVelocityY", 5 * math.sin(math.random(360))) |
Comments
and here's a wee example I made over breakfast
Thanks for the reply, I pretty much got it going after a bit of hair pulling, but I'm having an issue.
I can't seem to add a physics sprite into a group and have it effected by the physics world (probably doing something wrong here).
Instead I have to add it to the scene e.g:self:addChild(sprite)
What I really need to do is to add it to a group I've created called 'bg' - bg:addChild(sprite)
Everything is working fine when I don't try and add it to the group.
This probably has something to do with me not understanding how the physics world etc. works.
Any ideas would be awesome!
Thanks again!
Thanks heaps for your help!
Likes: antix
Thank for the tip, I'll keep that in mind!
In this case I'm only using 4 small physics objects that get destroyed after half a second, so it should not cause any performance issues