kinematic and static?

hey guys,

sorry about my obnoxious questions, but i have my walls set as static, and my triangle set as kinematic. well, when i drag my triangle to the walls, it goes right through. heres the code i have:

[code]
local leftWall = display.newRect(0, 0, 1, display.contentHeight )
localGroup:insert(leftWall)
local rightWall = display.newRect(display.contentWidth, 0, 1, display.contentHeight )
localGroup:insert(rightWall)
local ceiling = display.newRect(0, 0, display.contentWidth, 1 )
localGroup:insert(ceiling)
local floor = display.newRect(320, 0, 1, 480)
localGroup:insert(floor)
physics.addBody(floor, “static”, {bounce = 0.0} )
physics.addBody(leftWall, “static”, { bounce = 0.0} )
physics.addBody(rightWall, “static”, { bounce = 0.0} )
physics.addBody(ceiling, “static”, { bounce = 0.0} )

local wall = display.newImage( “Shortwall1.png”, 100, 400 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 150, 400 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 150, 386 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 0, 400 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 150, 350 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 150, 300 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 100, 350 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 100, 300 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 250, 300 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 100, 215 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 100, 201 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 200, 122 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 50, 120 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 50, 133 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 50, 200 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 50, 280 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 0, 280 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 0, 200 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 0, 133 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 0, 50 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, -10, 50 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 150, 48 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 150, 0 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 100, -22 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 250, 228 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall1.png”, 250, 90 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local wall = display.newImage( “Shortwall2.png”, 150, 78 )
physics.addBody(wall, “static”, { bounce = 0.0} )
localGroup:insert(wall)

local triangle = display.newImage( “triangle.png” )
physics.addBody(triangle, {density=.8, friction=.3, bounce=.6})
localGroup:insert(triangle)

local speedX = 0
local speedY = 0
local prevTime = 0
local prevX = 0
local prevY = 0
local function drag( event )
local triangle = event.target

local phase = event.phase
if “began” == phase then
display.getCurrentStage():setFocus( triangle )

triangle.x0 = event.x - triangle.x
triangle.y0 = event.y - triangle.y

event.target.bodyType = “kinematic”

event.target:setLinearVelocity( 0, 0 )
event.target.angularVelocity = 0

else
if “moved” == phase then
triangle.x = event.x - triangle.x0
triangle.y = event.y - triangle.y0
elseif “ended” == phase or “cancelled” == phase then
display.getCurrentStage():setFocus( nil )
event.target.bodyType = “dynamic”
triangle:setLinearVelocity(speedX, speedY)
end
end

return true
end
triangle:addEventListener(“touch”, drag)

[code]
thanks in advance! Any help would be greatly appreciated!
[import]uid: 19836 topic_id: 7849 reply_id: 307849[/import]

does it have something to do with kinematic and static or is that fine? [import]uid: 19836 topic_id: 7849 reply_id: 27999[/import]

b2_kinematicBody
A kinematic body moves under simulation according to its velocity. Kinematic bodies do not respond to forces. They can be moved manually by the user, but normally a kinematic body is moved by setting its velocity. A kinematic body behaves as if it has infinite mass, however, Box2D stores zero for the mass and the inverse mass. Kinematic bodies do not collide with other static or kinematic bodies

note the last sentence [import]uid: 6645 topic_id: 7849 reply_id: 28007[/import]

Oh okay i understand. So should i change it to Dynamic or is there something else to change it to? [import]uid: 19836 topic_id: 7849 reply_id: 28016[/import]

you might want to check the Physics/DebugDraw example for how to do physics-based dragging [import]uid: 6645 topic_id: 7849 reply_id: 28018[/import]

okay i will check those out. [import]uid: 19836 topic_id: 7849 reply_id: 28019[/import]

You can set the screen bounds/wrapper so the triangle can’t move off screen, I found this code on peach pellen’s site. She’s got a bunch of useful stuff for you.

[code]

local function wrap (e)

if triangle.x < 0 then
triangleRight.x = 300

end

if triangleRight.x > 300 then
triangleRight.x = 0

end
end

Runtime:addEventListener(“enterFrame”, wrap)
[/code] [import]uid: 13560 topic_id: 7849 reply_id: 28096[/import]