Pixel-Composer/scripts/node_rigid_global/node_rigid_global.gml

30 lines
891 B
Text
Raw Normal View History

2023-02-28 09:43:01 +01:00
function Node_Rigid_Global(_x, _y, _group = noone) : Node(_x, _y, _group) constructor {
2023-01-25 06:49:00 +01:00
name = "RigidSim Global";
color = COLORS.node_blend_simulation;
icon = THEME.rigidSim;
w = 96;
min_h = 96;
object = noone;
2023-02-14 05:32:32 +01:00
inputs[| 0] = nodeValue("Gravity", self, JUNCTION_CONNECT.input, VALUE_TYPE.float, [ 0, 10 ])
2023-01-25 06:49:00 +01:00
.setDisplay(VALUE_DISPLAY.vector);
current_gra = [0, 0];
2023-07-06 19:49:16 +02:00
static update = function(frame = PROJECT.animator.current_frame) {
2023-01-25 06:49:00 +01:00
var _gra = inputs[| 0].getValue();
2023-02-14 05:32:32 +01:00
if(current_gra[0] != array_safe_get(_gra, 0) || current_gra[1] != array_safe_get(_gra, 1)) {
2023-01-25 06:49:00 +01:00
physics_world_gravity(_gra[0], _gra[1]);
current_gra[0] = _gra[0];
current_gra[1] = _gra[1];
}
}
2023-03-05 07:16:44 +01:00
static onDrawNode = function(xx, yy, _mx, _my, _s, _hover, _focus) {
2023-01-25 06:49:00 +01:00
var bbox = drawGetBbox(xx, yy, _s);
draw_sprite_fit(s_node_rigidSim_global, 0, bbox.xc, bbox.yc, bbox.w, bbox.h);
}
}