MY PROBLEM IS SOLVED (it isn’t the problem described above, though) – see all the way to the bottom. Yes, my problem was something else, but just in case someone else encounter similar problem, I thought I’d share this. So… here it is:
My game is also born out of Simple Pool that came with the SampleCode. And YIKES, I got the sticky wall – just came up last night, and I could not find the way to fix it. I can’t even see why it’s not working. It makes zero sense to me.
The thing is, I’m not sure if changing the velocityThreshold parameter would make any difference – at least not with the problem I’m having.
I have four walls surrounding a rectangle “table”. I’m calling these walls bumpers (just like it does in Simple Pool project.) The top & bottom bumpers work just as expected while the right & left bumpers don’t. When I hit the “cueball” super hard (or very soft, or whatever – velocity doesn’t have anything to do with this) against the right/left wall, it gets stuck, while it bounces back perfectly fine from top/bottom bumpers. I can’t unstick the “cueball” once it’s glued on to a bumper.
Here are bumper settings for all four bumpers I’m having problem with. Notice how bumperBody settings are identical, except for the shapes of the bumpers. (Note: All local variables are being forward referenced at the top of my lua module).
bumperShapeWall1 = {-220,-20, 220,-20, 220,0, -220,0}
bumperShapeWall2 = {0,-220, 0,220, 20,220, 20,-220}
bumperShapeTriangle1 = {-98,0, 98,0, 0,30} -- triangle top/bottom
bumperShapeTriangle2 = {20,-135, 20,135, 50,0} -- triangle right/left
bumperBody1 = {friction=0.5, bounce=0.5, shape=bumperShapeWall1}
bumperBody2 = {friction=0.5, bounce=0.5, shape=bumperShapeWall2}
bumperBody3 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle1}
bumperBody4 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle2}
-- top bumper
imgWidth = 320;
imgHeight = 60;
posX = 0.5 \* (screenW - imgWidth);
posY = 25;
local boardBumper1 = display.newRect(posX, posY, imgWidth, imgHeight);
boardBumper1.alpha = 0;
physics.addBody(boardBumper1, "static", bumperBody1, bumperBody3);
-- bottom bumper
posY = 395;
local boardBumper2 = display.newRect(posX, posY, imgWidth, imgHeight);
boardBumper2.alpha = 0;
boardBumper2.rotation = 180;
physics.addBody(boardBumper2, "static", bumperBody1, bumperBody3);
-- left side bumpber
imgWidth = 60;
imgHeight = 380;
posX = -45;
posY = 49;
local boardBumper3 = display.newRect(posX, posY, imgWidth, imgHeight);
boardBumper3.alpha = 0;
physics.addBody(boardBumper3, "static", bumperBody2, bumperBody4);
-- right side bumper
posX = 305;
local boardBumper4 = display.newRect(posX, posY, imgWidth, imgHeight);
boardBumper4.alpha = 0;
boardBumper4.rotation = 180;
physics.addBody(boardBumper4, "static", bumperBody2, bumperBody4);
By the way, I tried using PNG image of the bumpers (i.e., instead of using display.newRect, I used display.newImage for the bumpers with exact shape), but it didn’t make any difference.
EDIT:
Based on Danny’s comment, I re-did the bumpers, and it worked! Thanks Danny!
http://developer.anscamobile.com/forum/2011/02/11/sticky-walls#comment-51781
So, just in case someone else is having a similar trouble, here’s the bumper shapes that worked. Compere the ones from the above to this one, and you’ll see what needed to be done.
local bumperShapeWall = {-220,-20, 220,-20, 220,0, -220,0}
local bumperShapeTriangle1 = {-98,0, 98,0, 0,30} -- triangle top
local bumperShapeTriangle2 = {-135,0, 135,0, 0,30} -- triangle right/left
local bumperBody1 = {friction=0.5, bounce=0.5, shape=bumperShapeWall}
local bumperBody2 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle1}
local bumperBody3 = {friction=0.5, bounce=0.5, shape=bumperShapeTriangle2}
[import]uid: 67217 topic_id: 3536 reply_id: 51776[/import]