Okay, after a lot of tests, I found out that is not only the upward slope that fails, it seems that the hero will go through and fall any floor object when it collides from the side instead of the top. (instead of pushing back the hero or allowing him to go up the slope).
Here is how I set up the bodies:
--setup first 8 floor pieces
for a = 1, 8, 1 do
isDone = false;
--get a random number
local mRand = math.random;
local myRand = mRand(1, 5);
local newBlock;
if(myRand == 1 and isDone == false) then
newBlock = sprite.newSprite(floorSets["A1"]);
physics.addBody( newBlock, "kinematic", { friction=0.3, bounce=0.4 } );
isDone = true;
end
if(myRand == 2 and isDone == false) then
newBlock = sprite.newSprite(floorSets["A2"]);
physics.addBody( newBlock, "kinematic", { friction=0.3, bounce=0.4 } );
isDone = true;
end
if(myRand == 3 and isDone == false) then
newBlock = sprite.newSprite(floorSets["A3"]);
physics.addBody( newBlock, "kinematic", { friction=0.3, bounce=0.4 } );
isDone = true;
end
if(myRand == 4 and isDone == false) then
newBlock = sprite.newSprite(floorSets["A4"]);
diagShape = { -40,120, 40,120, 40,-120, -40,-90 };
physics.addBody( newBlock, "kinematic", { friction=0.3, bounce=0.4, shape=diagShape } );
isDone = true;
end
if(myRand == 5 and isDone == false) then
newBlock = sprite.newSprite(floorSets["A5"]);
diagShape2 = { -40,120, 40,120, 40,-90, -40,-120 };
physics.addBody( newBlock, "kinematic", { friction=0.3, bounce=0.4, shape=diagShape2 } );
isDone = true;
end
newBlock.name = ("block" .. a);
newBlock.id = a;
newBlock.x = (a \* 80) - 80;
newBlock.y = 400;
blocks:insert(newBlock);
end
--setup hero's body
heroShape = { -20,50, 20,50, 20,-50, -20,-50 };
physics.addBody( hero, "dynamic",{ density = 0.3, friction = 0.6, shape=heroShape } );
What I do next is simply move all the ordered floorpieces to the left, to give the illusion of movement. (in here I used setLinearVelocity, but I also tried using translate, to the same result).
--update block movement
function updateBlocks()
for a = 1, blocks.numChildren, 1 do
(blocks[a]):setLinearVelocity(moveSpeed,0);
end
end
[import]uid: 136402 topic_id: 28736 reply_id: 116275[/import]