Showing posts with label neoforce. Show all posts
Showing posts with label neoforce. Show all posts

Wednesday, 17 February 2010

HS: Neoforce and variable rate game clock

Implementing the game clock was really very easy. I just have a class with an internal DateTime that has its ticks incremented by gameTime * timeRate, where time rate is set by one of the Neoforce buttons in the top left of the screen:


I initially subclassed Neoforce.Button, because I couldn't see how to otherwise pass custom data into the button click. I don't think I've really worked it out properly now, either, but I am now using the "Tag" property, both for this and for game difficulty selection:


Pushing the 'new game' button toggles the dialog box open and closed. Annoyingly, the Dialog box comes with default caption and description set, and it took me a while to figure out that you need to do dialog.TopPanel.Description.Text to access (and remove) it, despite C# allowing you to make string assignments to dialog.TopPanel.Description.

Anothing thing to note is that when a dialog is closed, it is not removed, simply marked as visible=false - which was exactly what I wanted, since I wanted the ability to bring it back easily. But I can see how it might not be everyone's preferred choice. Presumably to remove it entirely you need to remove it from the Neoforce Manager.

Finally, the background image for the start screen was taken from here. I am always grateful that so many people make their flickr photos CC-Attribution licensed. You can see that the photographer is credited on my start screen, too.

Wednesday, 10 February 2010

HS: Neoforce "no skin loaded" bughunt

Neoforce threw up another problem late last night: no matter what I did, I could not manage to get it to run without throwing up a runtime error the first time I try adding a button to my game mode: "Control cannot be created. No skin loaded." - another user had the problem on the Neoforce forum, but no solution was identified there.

The only way I found to get the project to start correctly was to ensure I was using the 4-parm constructor for the Neoforce Manager class and setting the register parm to true. The downside to this is that the manager automatically registers itself with your game class and the base game class calls the manager's draw and update methods. This could be inconvenient for you, but seems to be working okay for me at the moment.

Since I am writing a game with a mode switcher, I added an Exit method to the IGameMode interface that gets called on the current mode whenever the GameModeManager is about to change mode. In the GameModeMenu's Exit method I call Dispose on the Neoforce manager and set my reference to the manager to null. Hopefully this is enough to release the manager to be garbage collected; I don't see a method in either Game or the Neoforce manager to deregister it.

Tuesday, 9 February 2010

HS: Neoforce setup

I am on my way to getting neoforce controls set up. The first infuriating incident I came across was that neoforce requires its skins to be available - fair enough - but it's impossible to add folders to the XNA game studio's Content folder using the "add" method; you have to just drag the folder over. And again, to stop the auto-importer from getting confused, all of the skin files needed to be individually set to "copy if newer" and "no build action".

HS: UI beginnings

I had a hell of a time trying to find a window manager for XNA because I wasn't using the right search keyword, which turned out to be GUI. There are a whole load of XNA GUIs, I am going to try out Neoforce controls, because despite barely being in Beta, they look like they are still under development and the demo looks pretty snazzy. I'll let you know how I get on with it.

My first game mode is part-way written now; I've built the main menu mode, and got an image that I got from flickr creative commons loading as the background. It'll do for now. Eventually I plan to replace the static image with some sort of 3D thing, though I'm not sure what of yet.