Navigation inside scene

I am trying to add several areas inside a game without using separate scenes each area will be 1280x720 with arrow buttons like right, left, up and down to access another area.

I thought about moving the camera to another position if the arrow keys are clicked but this didn’t seem to work as I couldn’t find any move camera function just X and Y position.

Is it possible to move the camera or make the new area appear when an arrow is clicked ?

Thank for any help

This is a quick image to show what I mean

So you discovered change camera X and Y
How about change it to some object like even a square you hide at beginning of the scene
And moving that object and camera would follow

That is best trick you will ever learn in game making
You should not care how is something done
But what player will see on screen

Other method would be to just change X and Y os of camera to some other X and Y pos if some arrow key is pressed

Either way you will need few conditions to limit when it can move and when not
So player be unable to go out of bounds

If you don’t want to go with object i think most reasonable way would be to go with 2 variables call them like idk XCam YCam
You set them to something and you check if they are higher or lower than some value
And that would be your limiters to when what arrow key would trigger camera change

How about if Right arrow button is pressed, then camera X Pos += 1280. If Left arrow then camera X Pos -= 1280.
For Up arrow, camera Y pos -= 720. Down arrow, camera Y Pos += 720.
All trigger once.

I am not using my PC now and can’t try it, we can use -= and += right? I forgot.

This one work, camera will move.
Change the X and Y position directly, but the camera will instantly move or use tween camera so the camera will move smoothly.

1 Like

Still having a few issues almost got it working but the problem is quite a few times when player skip clicks the mouse on a arrow it seems to skip an area and go to the next one.

these are the events I am trying to use to canter the camera on different in game areas

Thanks

Try this,

Use currentPlace variable to indicate which area you are at.

Here’s an example of scene objects set-up
Make sure the ‘arrow buttons’ are in a layer above your Area screen which is in this case ‘Base layer’.
Otherwise when moving the ‘Base layer’ camera the arrows won’t stick to the screen.

Heres the events tab set-up.
The currentPlace number correspond the which object the camera is centering at.
Change buttons actions accordingly to the corresponding currentArea.

To use center camera action is this:

Also, in order to control or know the center X or Y, your scene object needs to be an sprite object. You can edit it with the [Edit Points] button located at the bottom-left when editing the object

Also, if you want to turn your arrows into buttons you can use ‘Button States’ behaviour. This way you don’t require hovering and left press conditions.

If you’re going to use more than 4 areas though.

For performance’s sake consider doing:

  • Button click with sub-event

  • And if you are going to lose track of your events. Maybe change it into text instead of numbers. Or even structures would work too as long as the number/text is different for each child.

1 Like

Thank you I ended up going with sub events as I added a couple of extra areas.