I don’t know if this is a bug or if I am doing something wrong but here goes.
I was plying around with physics and custom shapes and discovered that sometimes there is something wrong with the shape. It doesn’t look as expected and and on collision it doesn’t seem to recognize its boundaries. To get the coordinates of the custom shapes I use FW Physics Shape Plugin.
In the example bellow I have a “Tetris t-block shape” with coordinates (relative to its center) -60,0, -20,0, -20,-40, 20,-40, 20,0, 60,0, 60,40, -60,40
Here is a small example code
os.execute('clear');
display.setStatusBar(display.HiddenStatusBar);
local physics = require("physics");
physics.start();
physics.setGravity(0, 9.8);
physics.setDrawMode("debug");
local ground = display.newRect(0, 920, 660, 40)
physics.addBody(ground, "static", { density=3.0, friction=0.5, bounce=0.1});
local block = display.newRect(240, 600, 80, 80 );
physics.addBody( block, "dynamic", { density=3.0, friction=0.5, bounce=0.1});
local block2 = display.newRect(340, 600, 80, 80 );
physics.addBody( block2, "dynamic", { density=3.0, friction=0.5, bounce=0.1});
local vert = display.newRect(300, 800, 0, 0);
tBlock = {-60,0, -20,0, -20,-40, 20,-40, 20,0, 60,0, 60,40, -60,40}
physics.addBody( vert, "dynamic", { density=3.0, friction=0.5, bounce=0.1, shape=tBlock });
This is what I get from the code (before and after collision)
See how the t-block looks strange. Any idea why this is happening?
[import]uid: 41041 topic_id: 10928 reply_id: 310928[/import]