MCPcopy Create free account
hub / github.com/defold/defold / LuaSetXAnchor

Function LuaSetXAnchor

engine/gui/src/gui_script.cpp:2909–2930  ·  view source on GitHub ↗

sets the x-anchor of a node * The x-anchor specifies how the node is moved when the game is run in a different resolution. * * @name gui.set_xanchor * @param node [type:node] node to set x-anchor for * @param anchor [type:constant] anchor constant * * - `gui.ANCHOR_NONE` * - `gui.ANCHOR_LEFT` * - `gui.ANCHOR_RIGHT` */

Source from the content-addressed store, hash-verified

2907 * - `gui.ANCHOR_RIGHT`
2908 */
2909 static int LuaSetXAnchor(lua_State* L)
2910 {
2911 int top = lua_gettop(L);
2912 (void) top;
2913
2914 HNode hnode;
2915 InternalNode* n = LuaCheckNodeInternal(L, 1, &hnode);
2916 (void) n;
2917
2918 int anchor = luaL_checkint(L, 2);
2919 if (anchor != XANCHOR_NONE && anchor != XANCHOR_LEFT && anchor != XANCHOR_RIGHT)
2920 {
2921 luaL_error(L, "Invalid x-anchor: %d", anchor);
2922 }
2923
2924 Scene* scene = GuiScriptInstance_Check(L);
2925
2926 SetNodeXAnchor(scene, hnode, (XAnchor) anchor);
2927
2928 assert(top == lua_gettop(L));
2929 return 0;
2930 }
2931
2932 /*# gets the y-anchor of a node
2933 * The y-anchor specifies how the node is moved when the game is run in a different resolution.

Callers

nothing calls this directly

Calls 6

lua_gettopFunction · 0.85
LuaCheckNodeInternalFunction · 0.85
luaL_errorFunction · 0.85
GuiScriptInstance_CheckFunction · 0.85
SetNodeXAnchorFunction · 0.70
assertFunction · 0.50

Tested by

no test coverage detected