Jump to content

Controls in game outside the camera


montane
 Share

Recommended Posts

I'm have a camera effect in my game that shakes the camera when you shoot an enemy. However, the game has to have some on screen buttons for tablet devices and I don't want these to shake. Ive currently got these in a group. Is it possible to have these outside of the camera so they aren't affected by the shake?

Link to comment
Share on other sites

Hi, thanks for the reply! I appreciate it. If I set the controls group to have fixed to camera, then they are fixed to the position of the camera. However, the camera.shake() method shakes the camera which includes my controls. 

Link to comment
Share on other sites

Add your controls to the stage instead of the world, like "this.game.stage.addChild(controlSprite);". The camera view works by offsetting the position of the world so your controls should be safe there.

One consequence of that is you'll have to manage removing them on state transition since, by default, the StateManager clears the world on state transition.

Link to comment
Share on other sites

@olemoritz I tried it first but the use of fixedToCamera is voided by shaking the camera :) Perhaps the shake effect would be good to have a option to shake either the world or the camera as camera shake (observer shaking) may be desired or world shake maybe desired (earthquake etc).

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...