Skip to content

spriteanimationbutton

Thomas edited this page Aug 24, 2020 · 3 revisions

obj_uiZ_spriteanimationbutton

This is a object is just a button for inputting boolean values, but it uses a sprite driven animation. By default uiZ shows a hamburger menu button that changes into a back button. (see visualisation)

The sprite exists out of two parts: one opening and one closing animation. These two parts can be of different lengths but the total sprite size should be a minimal of 3 images. The animation of the sprite should preferably be a linear animation because uiz can add animations afterwards. When the value of the button is "false" and all animation are finished then frame 0 in the sprite will be displayed.

There is an image index in your sprite called the "endframe". When the value of the button is "true" and all animation are finished then the endframe in the sprite will be displayed. Mostly the "endframe" is about equal to the amount of frames/2.

The first frame should be an image of your button in the "false" state. After that there should be the "on animation" (the button becoming "true" while it was "false" before). Then there should be a frame depicting the button in its "true" state. (This is the endframe). After that you should end with a closing animation which morphs into frame 0.

Property variables

  • sprite[spr_uiz_menuanimationbutton]: The sprite to use.
  • color[c_white]: The color blend with which the sprite should be drawn.
  • endframe[25]: This should be the image index at which the opening animation is done. This is also the image which gets displayed when the value of the button is true. (e.g. pressed).
  • animationin[uiz_acceldecel]: The animation to use for when the button is being set to "true".
  • animationintime[0.6]: The time in seconds it will take for "animationin" to happen. This is the time it takes for the button to go from a "false" state to a "true" state after it is pressed.
  • animationout[uiz_acceldecel]: The animation to use for when the button is being set to "false".
  • animationouttime[0.5]: The time in seconds it will take for "animationout" to happen. This is the time it takes for the button to go from a "true" state to a "false" state after it is pressed.

Readable variables

  • update: Whenever an animation is going on, this will be true.
  • updated: Whenever the user has clicked the button, this will be true but only for one step.
  • value: Boolean holding the value of the button.

Functions

  • uiz_spriteanimationbutton_setvalue(instance id,value): Change the state of the button as if it was clicked.
    • instanceid: the instance id of the instance you want to modify
    • value: What value the button should have. (Either true or false). If value is not set to a boolean value, the buttons state is switched.
  • intervalue = uiz_spriteanimationbutton_getintervalue(instance id): Gives a interpolated but not animated value of the state of the button, ranging from 0 to 1.
    • intervalue: A number between 0 and 1 (linear with time) representing the progress of the button in moving from one state to the other.
    • instanceid: the instance id of the instance you want to modify
  • intervalue = uiz_spriteanimationbutton_getintervalue_animation(instance id): Gives a interpolated and animated value of the state of the button, ranging from 0 to 1.
    • intervalue: A number between 0 and 1 (but with an animation applied) representing the progress in the animation of the button.
    • instanceid: the instance id of the instance you want to modify
  • isInAnimation = uiz_spriteanimationbutton_isinanimation(instance id): Returns bool whether the button is in an animation.
    • isInAnimation: whether the button is currently in an animation
    • instanceid: the instance id of the instance you want to modify
  • uiz_spriteanimationbutton_setvalue_advanced(instance id,linearvalue,tovalue,update): Change the state of the button and it's animation.
    • instanceid: the instance id of the instance you want to modify
    • linearvalue: A value from 0 to 1 showing how far the button should be in it's animation. Set to 0 if you want the entire animation to be ran and set to 1 if you want no animation.
    • tovalue: The new value that should be used and that the animation has to work to. Making this -1 will use whatever the button is doing at that moment.
    • update: Whether to send out an "update" signal. Setting this to false doesn't set update=true, while setting this to true does.
  • uiz_spriteanimationbutton_setcolor(instanceid,color[c_white]):
    • instanceid: the instance id of the instance you want to modify
    • color: what color blend should be applied to the sprite this object draws.
  • uiz_spriteanimationbutton_setsprite(instanceid,sprite[spr_uiz_menuanimationbutton],endframe[25]):
    • instanceid: the instance id of the instance you want to modify
    • sprite: The sprite this object should draw
    • endframe: This should be the image index at which the opening animation is done. This is also the image which gets displayed when the value of the button is true. (e.g. pressed).
  • uiz_spriteanimationbutton_setanimation(instanceid,animationin[uiz_acceldecel],animationintime[0.6],animationout[uiz_acceldecel],animationouttime[0.6]):
    • instanceid: the instance id of the instance you want to modify
    • animationin: The animation to use for when the button is being set to "true".
    • animationintime: The time in seconds it will take for "animationin" to happen. This is the time it takes for the button to go from a "false" state to a "true" state after it is pressed.
    • animationout: The animation to use for when the button is being set to "false".
    • animationouttime: The time in seconds it will take for "animationout" to happen. This is the time it takes for the button to go from a "true" state to a "false" state after it is pressed.
  • value = uiz_spriteanimationbutton_getvalue(instanceid):
    • value: Boolean holding the value of the button.
    • instanceid: the instance id of the instance you want to modify

Visuals

This image has been generated using:

o=uiz_c(obj_uiZ_spriteanimationbutton);
uiz_setParent(o,win);//win is a window created before this snippit
o.posinframex=uiz_center
o.posinframey=uiz_center
o.posvalwtype=px;
o.posvalw=40;
o.posvalhtype=px;
o.posvalh=40;
o.animationintime=1.5;
o.animationouttime=1.5;
uiz_fixgeneralpos(o);

The sprite used for this spriteanimationbutton looks like this:

Wiki pages

🏑Home / General
πŸ“ƒTutorials
πŸ‘ͺ Parent
↕️ Positioning
πŸ›  Fixing & Updating
πŸ• Depth
πŸ“ƒ Templates and Examples
πŸŒ† Background
πŸ“‡ 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


🎈 Your own objects
🚫 Destroy
🐭 Mouse
πŸ’» Windows (uiz)
🌌 Animations
❓ General
πŸ“’ Numbers
πŸ“’ Strings
✏️ Draw
🚩 Popup
πŸ“‚ Files
πŸ’» Windows (os)
Clone this wiki locally