SetCamera()

  ... the case you feel the need for a new feature or want to submit one.

SetCamera()

Postby AfroFire » Sat Nov 05, 2011 8:29 am

Can we please get a setCamera() method added to the Engine class? I currently split my game from a BaseGameActivity in to two Scenes (MenuScene & GameScene). Then I have a "SceneHandler" which lets me change my scenes. I was okay with having a single camera until I realized that moving the camera around in GameScene translated to motion in the MenuScene. Also, is there a reason this method doesn't exist already?
AfroFire
 
Posts: 27
Joined: Thu Aug 19, 2010 1:57 am

Re: SetCamera()

Postby alexandernst » Fri Jan 06, 2012 12:45 am

I'm interested in that feature too. Is it possible to change the current camera?
alexandernst
 
Posts: 28
Joined: Fri Dec 16, 2011 10:22 pm

Re: SetCamera()

Postby AfroFire » Fri Jan 06, 2012 3:22 am

alexandernst, if you're doing something similar to what I did I created a method in my SceneHandler that told the scene to save its current camera settings (pretty much the position information, and it was in a method called saveCameraSettings()). Then there was another method that restored the camera settings called: restoreCameraSettings(Camera).


The SceneHandler would then just call saveCameraSettings() on the scene, then change the current active scene, and then call restoreCameraSettings(mCamera) on the new scene. I recall this working well enough.

But yeah, changing the camera would've been a bit easier (not a whole lot, mind you, but easy enough). A camera is just a list of position and dimension information anyways... oh and a HUD in the case of AndEngine. That might need to be hidden or something.
AfroFire
 
Posts: 27
Joined: Thu Aug 19, 2010 1:57 am

Re: SetCamera()

Postby alexandernst » Fri Jan 06, 2012 4:57 am

Hi, thanks for the reply, anyways, that won't work for me. I'm using a Camera() for the main menu + settings/level chooser, but I'd like to use a BoundCamera().

That would be possible if I had one activity per scene, e.g., one activity for the main menu, one activity for the settings menu, one activity for the level chooser and one activity for the level (the actual game). But I opted for using just one activity and create a SceneManager that changes (load/run/unload) scenes when needed. That's why I'm actually looking for a method that will change the camera.

Maybe I was wrong from the begginig and I should have used one activity per scene? If so, I should start rewriting my project now as I'm still at the beggining.

Regards
alexandernst
 
Posts: 28
Joined: Fri Dec 16, 2011 10:22 pm

Re: SetCamera()

Postby AfroFire » Fri Jan 06, 2012 5:05 am

Hm, what you are stating is identical to what I had. I was able to make it work using a single camera that was shared by all of my scenes. Note that a BoundCamera *IS* a Camera.
AfroFire
 
Posts: 27
Joined: Thu Aug 19, 2010 1:57 am

Re: SetCamera()

Postby alexandernst » Fri Jan 06, 2012 5:09 am

So, you just used a BoundCamera for everything? Menu and game?
alexandernst
 
Posts: 28
Joined: Fri Dec 16, 2011 10:22 pm

Re: SetCamera()

Postby AfroFire » Fri Jan 06, 2012 5:59 am

Actually, it would appear I did.

Note: Bounding can be disabled if it is causing problems.
mCamera.setBoundsEnabled(true/false)
AfroFire
 
Posts: 27
Joined: Thu Aug 19, 2010 1:57 am

Re: SetCamera()

Postby alexandernst » Fri Jan 06, 2012 6:01 am

Cool, I'll try that and see if it works.
Thank you!
alexandernst
 
Posts: 28
Joined: Fri Dec 16, 2011 10:22 pm


Return to Features

Who is online

Users browsing this forum: marvellousmax and 8 guests