hello, i would like my game to make a sound when the object ( ball ) hits the wall, currently i have
if (ball.y# < 0 or ball.y# + ball.h# > height) and BallHitWall_Flag = 0
SetSpritePhysicsVelocity ( ball.spr, GetSpritePhysicsVelocityX ( ball.spr ), -GetSpritePhysicsVelocityY ( ball.spr ) )
PlaySound ( BallWallSound )
BallHitWall_Flag = 1
elseif ball.y# > 0 and ball.y# + ball.h# < height
BallHitWall_Flag = 0
endif
but the collision ( - the y velocity ) does not always work and the ball is left outside the screen. i would prefer to use
SetPhysicsWallTop ( 1 )
SetPhysicsWallBottom ( 1 )
but i do not know how to detect it
i was thinking of doing this with the physics walls:
if (ball.y# < 1 or ball.y# + ball.h# > height - 1) and BallHitWall_Flag = 0
PlaySound ( BallWallSound )
BallHitWall_Flag = 1
elseif ball.y# > 0 and ball.y# + ball.h# < height
BallHitWall_Flag = 0
endif
but i am not sure if it will work
any suggestions?