Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi all, This may be a silly question, but what is the best way to bring up an in-game menu, such as an equipment screen? I am using the first-person camera, so it would need to free the cursor temporarily, then the cursor return to the camera after close. Is this possible without custom behaviors and actions? |
||||
|
Check out ccbSetCursorVisible() in the documentation. You will also need to switch between a simple camera and the fps camera. I'm not sure how you'd do it without using a little JS. |
||||
|
That makes me wonder if I should just use 2D elements that I show and hide based off a button and release the cursor at that time. That seems like it'd be feasible. |
||||
|
You'll need to switch out of the FPS camera because the cursor is locked to the center of the screen when it is active. Normally I just parent the simple camera to the FPS camera and switch between them, showing the cursor when needed. |
||||
|
Oh, that's a good idea, so the camera will stay looking where the FPS camera is. |
||||
|
You'll need to update the targets of the two cameras to match each other. CC's default behaviors/actions are rather limited. The JS needed to do this is rather basic and not overtly complex. |
||||
|
I can make a behavior that links the two cameras together. Just let me know if you need help. You can make a basic inventory fairly simply but say using a black overlay and displaying images inside it that you can click on. There's no reason to use those little boxes people use. Lots of ways to go about it. |
||||
|
I may give it a go myself soon and bump the thread if I need assistance! I used to be a developer several years ago for a year, but it's been so long I'm admittedly a bit sheepish to get back into it. Y'know what they say, if you don't use it, you lose it. CC is still pretty robust out of the box, but you're right. I have had to use other people's custom behaviors and actions already. I might as well start making my own. |
||||
|
That's the spirit. Good luck with your project. |
||||
|
nightowljrm wrote: Hi all, This may be a silly question, but what is the best way to bring up an in-game menu, such as an equipment screen? I am using the first-person camera, so it would need to free the cursor temporarily, then the cursor return to the camera after close. Is this possible without custom behaviors and actions? There might be couple of things that you can do. In case you want your game scene to pause completely, you can simply create a separate menu scene and switch to it. Game scene will be paused but will not be reset, so if you switch back everything is the same as it was before you "paused". Improvement would be setting mouse cursor to center position before switching to the game scene, that way you can avoid immediate fps camera rotation. var halfWidht = ccbGetScreenWidth() / 2; Another approach, is as guest mentioned, to switch to a simple camera and show a 2d overlay. There are also a couple of things that you can do to make your life easier. First of all, make a root inventory element, which contains all its other elements as children. That way you only have to hide/show this element. Second thing, there is a strange behavior when switching from fps camera to a simple camera - in case you hold any of the movement buttons fps camera keeps moving, while not active. In order to avoid this behavior you can disable the input before switching the cameras using ccbEmulateKey: var KEY_W = 87; Switching cameras is pretty simple too. You're taking source camera position and target and then apply it to the target camera, then make the target camera active: function switchCams(source, target) { Remember to also set mouse cursor to center before switching back to the fps cam, overwise you will get it rotated right after the switch. |
||||
|
Also, you can check the example here:https://zeicmann.itch.io/ccb-var... |
|