Create a Button with no nodes on it You will need to add a child yourself and position accordingly.
Class Button
#include <Geode/ui/Button.hpp>Examples0
Public static methods5
staticgeode::Button*create(geode::Button::ButtonCallbackactivateCallback)
activateCallback
staticgeode::Button*createWithNode(cocos2d::CCNode*node,geode::Button::ButtonCallbackactivateCallback)
Create a Button with a nodes on it. The node will be automatically positioned in the center.
node
activateCallback
staticgeode::Button*createWithSprite(geode::ZStringViewfileName,geode::Button::ButtonCallbackactivateCallback)
Create a Button with a sprite by file name
fileName
activateCallback
staticgeode::Button*createWithSpriteFrameName(geode::ZStringViewframeName,geode::Button::ButtonCallbackactivateCallback)
Create a Button with a sprite by frame name
fileName
activateCallback
staticgeode::Button*createWithLabel(,,geode::Button::ButtonCallbackactivateCallback)
Create a Button with a label
text
font
activateCallback
Public member functions32
cocos2d::CCNode*getDisplayNode()
Get the Display Node, which was created or passed in on button creation Will be nullptr if you use the empty create method
voidsetAnimationType()
Set an animation type, which dictates how the button moves or scales or if it even has an animation at all
voidsetClickAnimation()
Set a click animation. This will override the AnimationType and set it to Custom. Will run every time the button is pressed
voidsetReleaseAnimation()
Set a release animation. This will override the AnimationType and set it to Custom. Will run every time the button is released
voidsetActivateCallback(geode::Button::ButtonCallbackcallback)
Set a callback for when the button is activated
voidsetSelectCallback(geode::Button::ButtonCallbackcallback)
Set a callback for when the button is selected
voidsetUnselectCallback(geode::Button::ButtonCallbackcallback)
Set a callback for when the button is unselected
intgetTouchPriority()
voidsetTouchMultiplier(floatmultipler)
Set the touch multiplier, which increases the distance from the center that the button can be pressed (default is 1)
floatgetTouchMultiplier()
voidsetScaleMultiplier(floatmultiplier)
Set the scale multiplier, only used with AnimationType::Scale Will scale the button by this amount when pressed
floatgetScaleMultiplier()
voidsetMoveOffset(cocos2d::CCPointconst&offset)
Set the move offset, only used with AnimationType::Move Will move the button by this amount when pressed
cocos2d::CCPointgetMoveOffset()
floatgetSelectedDuration()
voidsetUnselectedDuration(floatduration)
Set how long the default animations will last when unselected
floatgetUnselectedDuration()
virtualboolisEnabled()
virtualboolisSelected()
Get the selected state of the button