-
Notifications
You must be signed in to change notification settings - Fork 2
tutorial.basic.1
Hi, welcome to this 14 part basic uiZ tutorial. This is a very extensive tutorial for those who are beginner up to intermediate in using game maker. Still, a basic understanding of gml is required.
Let dive right into the first tutorial, shall we? We start off by creating A simple square. If you imported this asset into your project, then there should be an object called βobj_uiZ_squareβ. This is a simple object displaying a square of given color with an optional outline. To start off, create a new object (not the square, a new blank object) and place it in a empty room. We need initialize uiZ. We can easily do this by calling the script βuiz_init()β without any arguments inside the create event of the newly created object. To create an uiZ object, use the function uiz_c(), which is a very simple version of instance_create. Whereas instance_create takes an object, x and a y, uiz_c only takes an object. So calling uiz_c(obj_uiZ_square) in a create event should be fine. Uiz_c (and instance_create as well) should return an βinstance idβ about which you can read more in the game maker manual. But practically itβs a reference to our created object.
Example 1:
//create event of a newly created object.
//initialize uiz
uiz_init()
//create our square object
square = uiz_c(obj_uiZ_square)We have created our square, and the result should look like this:
IMAGE 1
Not a lot of stuff huh?β¦ But, try to resize your window! (if this isnβt working for you go to: Global Game Setting -> Windows -> Graphics and make sure βAllow the player to resize the game windowβ is checked.)
After you resized your window just A bit, you should see something like this:
IMAGE 2
You can now see a tiny white square on the top-left of your screen. Why isnβt this square being drawn immediately? Good question! The answer is that we forgot to βfixβ our object. Practically fixing is making sure that our object will we put into the right place and all object variables setup correctly. The reason why things worked when we resized the window is because every uiZ object will be automatically βfixedβ when we do that. How do we βfixβ? Very easy. Just call the script βuiz_fix()β. This is where the handle to our object comes in. Remember? It was the βSquareβ part in βsquare=uiz_c(obj_uiZ_square)β that now refers to the obj_uiZ_square object. We use this by putting inside the first argument of uiz_fix, like this:
Example 2:
//create event of a newly created object.
//initialize uiz
uiz_init()
//create our square object
square = uiz_c(obj_uiZ_square)
//fix our square object.
uiz_fix(square)Now our square will look like this from the beginning of our run:
IMAGE 2
There are generally 4 parts in uiz object generation:
- Creation
- Setting parents
- Setting variables/settings
- Fixing.
βCreationβ and βfixingβ is already covered and weβll cover parents in a different tutorial. Letβs focus on the variables/settings part. To get a good idea of all general uiz variables, please open op the uiz documentation: https://github.com/Tthecreator/uiZ/wiki. Open it up and click the βPositioningβ item. Here you can read about what ways there are to position and size your object. For now, we will just focus on positioning our object. By default, our object at position 0,0. You can see this in the screenshot above (the square is in the top-left corner). Letβs change our object position to 100x200 pixels! To do this call uiz_position(square, 100,px, 200,px); The first argument is a reference to our square. The second and third argument say that the x position of the object should be β100 pixelsβ (px is short for pixels). The fourth and fifth argument say that the y position of the object should be β200 pixelsβ. You can swap the βpxβ out for other values, but that is for a later tutorial.
Example 3:
//create event of a newly created object.
//initialize uiz
uiz_init()
//create our square object
square = uiz_c(obj_uiZ_square)
//setup some variables
uiz_position(square, 100,px, 200,px);
//fix our square object.
uiz_fix(square)
IMAGE 3
Ok, not so fast there! Let take a close look our function: βuiz_position(square, 100,px, 200,px);β. First of all remember our 4 points? Creation, parents, variables and fixing. Things are supposed to go in that order, thus we put our line which changes some setting of our object after setting the parent, which we didnβt do, so we have to put if between our create part, and our fixing part.
Now letβs try sizing! If you are still on the positioning wiki page, you can scroll all the way down to read about sizing. Let's use the uiz_size(instanceid, width, widthType, height, heightType) function. Let's say we want to change our size to 50x50 pixels. The default is 10x10 pixels as you can see in all previous screen shots.
Example 4:
//create event of a newly created object.
//initialize uiz
uiz_init()
//create our square object
square = uiz_c(obj_uiZ_square)
//setup some variables
uiz_position(square, 100,px, 200,px);
uiz_size(square, 50,px, 50,px);
//fix our square object.
uiz_fix(square)Weβll get something like this:
IMAGE 4
Congratulations again!, you are now able to:
- initialize uiz
- create an object
- set the position of a uiZ object in pixels.
- set the size of a uiZ object in pixels.
- fix your objects.
Just keep remembering the little βCreation, parenting, settings and fixingβ convention.
Next tutorial weβll be getting into parents.
πTutorials
Basics 1: Basic positioning
Basics 2: Parenting system
Basics 3: Advanced positioning
Basics 4: Advanced sizing and set point
Basics 5: Canvas and containment
Basics 6: Alpha and depth
Basics 7: Using the manual and Animations
Basics 8: Object backgrounds
Basics 9: Grids
Basics 10: Framesets
Basics 11: Windows
Basics 12: Scroll bars
βοΈ Positioning
π Depth
π Structures
π Objects
obj_uiZ_3waybutton
obj_uiZ_button
obj_uiZ_checkbox
obj_uiZ_clock
obj_uiZ_colorbox
obj_uiZ_cover
obj_uiZ_drawdslist
obj_uiZ_dropdown
obj_uiZ_easybutton
obj_uiZ_frame
obj_uiZ_framescrollbar
obj_uiZ_functionbar
obj_uiZ_gradientsquare
obj_uiZ_gradientroundrect
obj_uiZ_gridlist
obj_uiZ_huesquare
obj_uiZ_loadingbar
obj_uiZ_loadingcircle
obj_uiZ_menubutton
obj_uiZ_mousemenu
obj_uiZ_radiobox
obj_uiZ_rotator
obj_uiZ_slider
obj_uiZ_scrollbar
obj_uiZ_slider_2col
obj_uiZ_slickslider
obj_uiZ_slideframe
obj_uiZ_sprbutton
obj_uiZ_spriteanimationbutton
obj_uiZ_spritecounter
obj_uiZ_stringbox
obj_uiZ_sliderstruct
obj_uiZ_surfacecanvas
obj_uiZ_sprite
obj_uiZ_square
obj_uiZ_squarebutton
obj_uiZ_swipicon
obj_uiZ_switch
obj_uiZ_tabslider
obj_uiZ_tabs
obj_uiZ_treelist
obj_uiZ_text
obj_uiZ_text_background
obj_uiZ_textarea
obj_uiZ_valuebox
π Strings
uiz_addChar
uiz_changechar
uiz_charCanHaveAddon
uiz_returnCharAddon
uiz_charIsNumber
uiz_charIsNumberOrText
uiz_getlines
uiz_gettext_contained
uiz_gettextlines_contained
uiz_getValidVariableName
uiz_isSpaceChar
uiz_lastStringChars
uiz_removeChar
uiz_replaceChars_
uiz_string_copy
uiz_string_digits
uiz_string_format
uiz_string_fromReal
uiz_string_real_getFracLength
uiz_string_real_getIntLength
uiz_string_repeat
uiz_string_replace
uiz_string_pos_at
uiz_stringUntilNewline