Menu

Tag Archives: menu

Well – I did it. After slogging through the bullshit from my last post, I got everything laid out well.

There is one issue that I was having on the start screen after revamping things with regards to how the buttons work. In Unity you can create a button and have a transition effect (tint, scale or image swap). I did an image swap to match the game layout. I was reminded of why I did what I did when setting up the levels.

When I started this project, my initial thought was that I would have buttons be the main UI, just lay them out with the transition effect- all the animation code would be taken care of. There is a default state, a hover state (mouseOver), a pressed/clicked state and a disabled state. You can set images for each of those states. In my case, the hover state is a lighter square color. Pressing makes the state revert to “default” image.

Something stupid happened along the way. If you press down on a button, then it shows the “pressed” state… Then, while still holding the mouse down, drag your mouse off the button, it reverts the state of the button to the “hover” state. Even though the mouse is no longer hovering over it. It should revert to the default state, not act as if my mouse is still on it). This indicates that the mouse state detection only updates when a player releases the mouse.

When the mouse has no buttons being pressed, the mouse location is wherever the mouse actuall is on screen, and Unity seems to be able to deal with it as such… But, when you press the button, it seems to retain the location of where the mouse clicked, not where it is now. So when I leave the mouse position, while still having the mouse clicked, even though the mouse is no longer hovering over a button, when I leave the square, it acts as though the mouse has been released, and my location is still where it was when I clicked the square/button. I’m not going to waste time making a video now of it, but it’s annoying and I think that’s why I ended up doing something much more complicated than just using buttons for the state of my squares on the grid.

I forgot that was the case, however, and when creating the loading screen, started from scratch with… BUTTONS! And so now I have that dumb as shit issue. Oh well. Not going to worry about it. Too much work to try to fit my workaround from the gameplay into the level select screen.

Anyways, so the next bit of progress was saving a completed level to the playerprefs file so when you load the game, the next available level and all previous levels are now highlighted as selectable, and the player can do so. I need to do a little error checking because right now if I don’t have a level actually built, but the levelselect menu shows it as available, it will, of course, generate an error when clicking.

In the video below I demo the glitchy transition states for the buttons (note how I move off “4” and it suddently lights up? You’ll see when I hover over numbers they light up and if I press down, they go dark. If I move off while still pressed, they light up again as if I’m hovering over them (and will go dark if I move back over it)… only when I release the mouse button will it do the right thing).Then you can see how the available levels are highlighted when I return to the menu after completing a level.

So I started to make the menu system. Having to revamp the level select grid itself… Instead of sprites, I’m having to load them as UI Images (which can then be used as buttons). I forgot that’s how it worked so I struggled with that. Basically level select will appear to be the same sort of 5×5 grid as the gameplay, only with sequential numbers displayed in each square as opposed to the “move” values in the gameplay grid.

So I set it all up, finally got the first level to load (after figuring out the stupid “UI Image” issue), so I’m psyched, except…

Since I dragged the 5×5 grid from the prefab, I made the changes and I think I hit “Apply” which then applies the values of the changed items to the prefab item itself. Which means, the changes I made for the level select screen only got transferred into the game play screen.

This means that the of the squares are all wrong (as they apparently loaded in from the pre-fab). Except now I wonder how, exactly that worked, because I didn’t say to load it from the prefab. I dunno it’s confusing and I’m annoyed because now I have to go back in and redesign the levels (not hard, really just change some values). But still annoying.

So the tedious part of game programming/design is now in effect. Working on the menus and stuff. Refining and redesigning some things.

The major overhaul is getting rid of the score system. No more scoring. Just a binary finish level or no. If yes, then load next level, if not, can replay the current one.

Modified instructions to reflect that change. Removed the “Scores” button from the menu screen.

Added a few new simple levels to test for level transitions. Added fade in/out effects. Everything seems to be working on that front.

The next part will be to get my levelmanager to indicate whether a level is complete or not, and use that information for my level select. Basically the front screen will be the title, instructions button and the grid with level numbers. Available levels will be highlighted (the same way targetable squares are in the game). Non-available levels will be the purple level numbers (same as untargetable squares). I’m thinking I should change how the “completed” levels are indicated. I would think a faded pink would work, but in the game, that’s “current position”. Perhaps the blue I was using for the score. In the game, those completed squares are completely removed, but I don’t think I want to do that. I might just leave it as “targetable” rose color, because in theory you can play them again. Yeah maybe I’ll do that.

So I think that might be a bit tricky to get working (have to figure out how to save the state of completed or not completed levels). Maybe I can just store it as a single number in the levelmanager…. “Last Level Completed” or something. Then when loading the game, just read that, and color appropriately.

Anyways, this isn’t as fun, but it’s necessary to have a completed product and I’m refining the concept as I go, as well. Keep plugging away!

Also added a gallery of my art. If you’re curious, you can see it here