★ TouchArcade needs your help. Click here to support us on Patreon.

Only play a sound if a collision happens in view?

09-23-2015, 08:36 AM
#1
Joined: Sep 2015
Posts: 2
Only play a sound if a collision happens in view?

first post here, lurked for a little while so apologies if this is in the wrong place.

im working on a game where if there is a collision between two boddies then a sound plays. ive got this part working fine, but i only want the sound to play if the collision happens in the view. i have a scrolling background and collisions further ahead are making a noise.

any help would be appreciated.
09-23-2015, 09:40 PM
#2
Joined: Oct 2014
Posts: 62
Sounds pretty simple. There should be a rectangle to represent the size of the "view", check the collision point between the two objects that have hit each other. If the collision point is in the main view rectangle, play sound.