Sprite collision

So I have my sprite set on a transition

local playbutton = display.newImage( "play.png" )  
group:insert(playbutton)  
playbutton.x = display.contentWidth / 1.5  
playbutton.y = display.contentHeight / 12  
  
   
 playbutton.active = false  
local function buttonTouched(e) if e.phase == "began" then  
e.target.alpha = .5  
end if e.phase == "ended" then  
instance:play();  
trans1 = transition.to( instance, { time=15000, x = 1100 } )  
e.target.alpha = 1 print("Replay button was touched.")  
  
 if(instance.y \> 700) then  
transition.cancel(trans1)  
print("Transition Stopped")  
 end  
end  
 end  
   
playbutton:addEventListener( "touch", buttonTouched )  

However when my sprite runs into a wall it just keeps walking. Here’s my wall code.

local floor = display.newImageRect("floorlarge.png", 1000, 225, 1000, 225)  
group:insert(floor)  
floor.x = 890; floor.y =380  
  
physics.addBody(floor, "static", {density=3,friction=3,bounce=0})  
floor.name = "floor"  

Not sure why the sprite walks right through it. [import]uid: 72845 topic_id: 35278 reply_id: 335278[/import]

Hi FL,
How is your collision sensing implemented? Can you post that part of the code?

Brent [import]uid: 200026 topic_id: 35278 reply_id: 140236[/import]

I guess thats my what my current problem is. What I don’t understand is when the sprite lands on the floor it detects that its on the floor. When I move the floor up creating a wall it just walks right through it. Its like the sprite detects the y collision but not an x collision.

Here’s the other part of my sprite code, I know its not the most up to date but I’m taking baby steps.

local screen = display.newGroup()  
   
local instance = sprite.newSprite(set);  
instance.x = display.contentWidth/70   
physics.addBody(instance, {bounce = 0.2, friction = .1})  
 group:insert(screen)  
instance.name = "gnomie"  
instance.angularDamping = 5000  
instance.isFixedRotation = true  
instance.isAlive = yes  

I know this isn’t what you asked for but I don’t have anything that specifies collision right now. Or at least it appears that way.

Also I bought one of those books you recommended. Along with watching video tutorials on things I’m hoping to be self sufficient in the future. [import]uid: 72845 topic_id: 35278 reply_id: 140239[/import]

Hi FL,
So, you haven’t put in physical collision sensing yet? Are you sensing it just by checking the object’s Y position? If you want real, active collision detection, you’ll need to go all the way… and that’s when the fun part begins! Seriously, it’s fun, if you like physics. :wink:

http://developer.coronalabs.com/content/game-edition-collision-detection

Brent [import]uid: 200026 topic_id: 35278 reply_id: 140300[/import]

Hi FL,
How is your collision sensing implemented? Can you post that part of the code?

Brent [import]uid: 200026 topic_id: 35278 reply_id: 140236[/import]

I guess thats my what my current problem is. What I don’t understand is when the sprite lands on the floor it detects that its on the floor. When I move the floor up creating a wall it just walks right through it. Its like the sprite detects the y collision but not an x collision.

Here’s the other part of my sprite code, I know its not the most up to date but I’m taking baby steps.

local screen = display.newGroup()  
   
local instance = sprite.newSprite(set);  
instance.x = display.contentWidth/70   
physics.addBody(instance, {bounce = 0.2, friction = .1})  
 group:insert(screen)  
instance.name = "gnomie"  
instance.angularDamping = 5000  
instance.isFixedRotation = true  
instance.isAlive = yes  

I know this isn’t what you asked for but I don’t have anything that specifies collision right now. Or at least it appears that way.

Also I bought one of those books you recommended. Along with watching video tutorials on things I’m hoping to be self sufficient in the future. [import]uid: 72845 topic_id: 35278 reply_id: 140239[/import]

Hi FL,
So, you haven’t put in physical collision sensing yet? Are you sensing it just by checking the object’s Y position? If you want real, active collision detection, you’ll need to go all the way… and that’s when the fun part begins! Seriously, it’s fun, if you like physics. :wink:

http://developer.coronalabs.com/content/game-edition-collision-detection

Brent [import]uid: 200026 topic_id: 35278 reply_id: 140300[/import]