Tuesday, March 18, 2014

GameMaker: Studio GML GUI Scripting

I have to start off with this post that I am somewhat disappointed by the in game Graphical User Interface found in GameMaker: Studio. I understand that it is not a powerful engine like Unreal or idTech4 - but it goes without saying that there is more to a GUI than how it is rendered.

This is exactly how GM: S looks at it. The GUI is strictly a render-able object overlaid the rest of the view and bound to screen coordinates. It does not however; have any other aspect of the object, move with these traits. What do I mean by that?

Well, the collision mask (used by mouse click/enter/leave/etc. events) still stays in world-coordinates. Or in GameMaker terms, room coordinates. So if you have an object created at 0,0 and render itself in the Draw GUI Event, it will render with the center at the top left corner. But the collision masks will be place at the top left corner of you room. This was not the solution to using my shop UI.

Many suggested transforming the mask to the image per-step. Well, with that being said, you might as well as transform the whole thing. This then removes the need for Draw GUI and everything works as it should. So, what does this teach me? Two things:

1) Draw GUI Event is only for render only objects.
2) GameMaker: Studio needs better support for screen space coordinate UI features.

If anybody was wondering, here is the code to render and object consistently in view at a 'fixed point' (in relation to a view).

[In the Step Event]
if(close){
    instance_destroy();
}

x = view_xview[0];
y = view_yview[0];

for(i = 0; i < 4; i++){
    btn[i].x = view_xview[0] + 64;
    btn[i].y = view_yview[0] + 64*i + 32;
}

The btn array is a reference to buttons that occupy the shop UI. This way, one object manages all related instances.

The part that should be focused on is the following:

x = view_xview[0];
y = view_yview[0];

In conclusion, GameMaker: Studio is a good engine and I enjoy using it; however, it feels lacking in some features that require needless workarounds. But, I will continue developing in it.

1 comment:

  1. GameMaker Studio
    I am very impressed with your post because this post is very beneficial for me

    ReplyDelete