Camera Offset problem
Hi All,
Hoping somebody can help as I can't find this on the forums...
I'm trying to make an actor in my HUD invisible once another actor on my scene is on the screen (and then the HUD actor becomes visible when the actor on the scene is no longer on the screen). Is there an easy way to do this?
I've tried creating another transparent HUD actor called ScreenSensor that is the same size as my camera/screen (1,024 x 768) and constrain it to my camera's origin by using:
scene.Camera.Origin.X +( self.Size.Width /2)
scene.Camera.Origin.Y +( self.Size.Height /2)
I've also tried (which I think I found on a forum thread):
scene.Camera.Origin.X +( scene.Camera.Size.Width -( self.Size.Width /2))
scene.Camera.Origin.Y +( scene.Camera.Size.Height -( self.Size.Height /2))
...but neither work. The ScreenSensor never stays on the screen as I move about the scene (which is 2,000 x 2,000 btw). And therefore, my visibility rule for my HUD icon doesn't work.
Any advice appreciated!!!
Cheers,
HK
Comments
Is this actor on the scene moving ?
@Socks : No, the actor on the scene isn't moving, but the camera is moving around the scene. Thanks
Ah, I actually realized that my ScreenSensor Actor needed to be on the same layer as the actor it's sensing as it can't collide with a scrollable actor if it's in a non-scrollable layer.
To help those people searching for this issue in the future, this seems to work:
I've got an actor I call ScreenSensor the same size as my screen size (1,024 x 768) which I make invisible and put it on the scene in the same scrollable layer as my other actors. I constrain the X and Y position of ScreenSensor actor to the camera using the following formulas:
scene.Camera.Origin.X +( scene.Camera.Size.Width -( self.Size.Width /2))
scene.Camera.Origin.Y +( scene.Camera.Size.Height -( self.Size.Height /2))
... this will keep your ScreenSensor actor on the screen the whole time even as the camera moves around a scene. Now you can simply set rules so that when it collides with an actor you'll know that that actor is on the screen, and when it doesn't, that actor must be off the screen.
Hope this is useful for others!
Cheers,
HK