Play sound when actor in screen...

sebmacflysebmacfly Member Posts: 1,018
Hello!
Anybody know how to play a sound when an actor is in the screen?
For exemple, play a Fan cooler sound when i see it in the screen (with fade in and fade out audio...)

Thank you very much in advance

Comments

  • sebmacflysebmacfly Member Posts: 1,018
    no way?
    I just want to play an actor sound when he's visible on screen...
  • SlowboySlowboy Member, PRO Posts: 329
    How about an actor as big as the screen call OnScreen
    Then a rule, when FanCooler overlaps OnScrenn, play sound.
    I suppose you could fade in and out by having consecutively smaller OnScreen actors. When it overlaps with the outer one, play a quiet sound, then when it overlaps with the smaller ones, towards the centre of the screen, play a louder sound?
    Might just work?
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Just compare your actor's X and Y to the screen coordinates:

    If your camera does NOT move:

    In the Actor:

    Rule
    All
    When self.PositionX > 0
    When self.PositionX < 480
    When self.PositionY > 0
    When self.PositionY < 320
    [Play Sound] <------- use the new Interpolate Behavior or a Timer to fade the sound in

    If your camera DOES move:

    You'll need to keep track of the Camera.Origin.X and Camera.Origin.Y (the lower-left corner of the screen). Create two global integer attributes, cameraX and cameraY. Create a camera tracker actor and place him in the Scene. Double click on it and click its padlock to edit it's instance properties. Constrain the Camera.Origin.X and Y to those two global Attributes.

    In the Actor:

    Rule
    All
    When self.PositionX > game.CameraX
    When self.PositionX < (game.CameraX + 480)
    When self.PositionY > game.CameraY
    When self.PositionY < (game.CameraY + 320)
    [Play Sound] <------- use the new Interpolate Behavior or a Timer to fade the sound in

    Hope this helps!
    Joe
Sign In or Register to comment.