Particle path

This commit is contained in:
Tanasart 2024-01-10 14:37:15 +07:00
parent c3051fa4d2
commit 64f4707b45
5 changed files with 45 additions and 4 deletions

View File

@ -78,6 +78,11 @@ function __part(_node) constructor {
frame = 0;
path = noone;
pathIndex = 0;
pathPos = new __vec2();
pathDiv = noone;
static reset = function() { #region
INLINE
@ -168,6 +173,13 @@ function __part(_node) constructor {
alp_fade = _fade;
} #endregion
static setPath = function(_path, _pathDiv) { #region
INLINE
path = _path;
pathDiv = _pathDiv;
} #endregion
static kill = function(callDestroy = true) { #region
INLINE
@ -294,6 +306,14 @@ function __part(_node) constructor {
_xx = drawx + _pp[0];
_yy = drawy + _pp[1];
if(path != noone) {
var _div = pathDiv.get(lifeRat);
pathPos = path.getPointRatio(lifeRat, pathIndex, pathPos);
_xx = _xx * _div + pathPos.x;
_yy = _yy * _div + pathPos.y;
}
if(exact) {
_xx = round(_xx);
_yy = round(_yy);

View File

@ -150,12 +150,22 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
.setDisplay(VALUE_DISPLAY.button, { name: "Trigger", onClick: triggerSpawn, output: true })
.rejectArray();
inputs[| 45] = nodeValue("Follow Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.boolean, false )
.rejectArray();
inputs[| 46] = nodeValue("Path", self, JUNCTION_CONNECT.input, VALUE_TYPE.pathnode, noone )
.rejectArray();
inputs[| 47] = nodeValue("Path Deviation", self, JUNCTION_CONNECT.input, VALUE_TYPE.curve, CURVE_DEF_11 )
.rejectArray();
input_len = ds_list_size(inputs);
input_display_list = [ 32,
["Sprite", false], 0, 22, 23, 26,
["Spawn", true], 27, 16, 44, 1, 2, 3, 4, 30, 24, 5,
["Movement", true], 29, 6, 18,
["Follow path", true, 45], 46, 47,
["Physics", true], 7, 19, 33, 34, 35, 36,
["Ground", true, 37], 38, 39, 40,
["Rotation", true], 15, 8, 9,
@ -190,6 +200,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
curve_scale = noone;
curve_alpha = noone;
curve_path_div = noone;
for( var i = 0; i < attributes.part_amount; i++ )
parts[i] = new __part(self);
@ -235,6 +246,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
var _ground_bounce = getInputData(39);
var _ground_frict = getInputData(40);
var _path = getInputData(46);
if(_rotation[1] < _rotation[0]) _rotation[1] += 360;
var _posDist = [];
@ -330,6 +343,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
part.setGround(_ground, _ground_offset, _ground_bounce, _ground_frict);
part.setTransform(_scx, _scy, curve_scale, _rot, _rot_spd, _follow);
part.setDraw(_color, _bld, _alp, curve_alpha);
part.setPath(_path, curve_path_div);
spawn_index = safe_mod(spawn_index + 1, attributes.part_amount);
onSpawn(_time, part);
@ -389,9 +404,11 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
var _curve_sca = getInputData(11);
var _curve_alp = getInputData(14);
var _curve_pth = getInputData(47);
curve_scale = new curveMap(_curve_sca, TOTAL_FRAMES);
curve_alpha = new curveMap(_curve_alp, TOTAL_FRAMES);
curve_scale = new curveMap(_curve_sca, TOTAL_FRAMES);
curve_alpha = new curveMap(_curve_alp, TOTAL_FRAMES);
curve_path_div = new curveMap(_curve_pth, TOTAL_FRAMES);
#endregion
render();
@ -456,6 +473,7 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
var _dirAng = getInputData(29);
var _turn = getInputData(34);
var _spwTyp = getInputData(16);
var _usePth = getInputData(45);
inputs[| 6].setVisible(!_dirAng);
@ -470,6 +488,8 @@ function Node_VFX_Spawner_Base(_x, _y, _group = noone) : Node(_x, _y, _group) co
inputs[| 23].setVisible(false);
inputs[| 26].setVisible(false);
inputs[| 46].setVisible(true, _usePth);
inputs[| 1].setVisible(_spwTyp < 2);
if(_spwTyp == 0) inputs[| 1].name = "Spawn delay";
else if(_spwTyp == 1) inputs[| 1].name = "Spawn frame";

View File

@ -50,6 +50,7 @@ function Node_VFX_Group(_x, _y, _group = noone) : Node_Collection(_x, _y, _group
var loop = getInputData(0);
if(!loop) return;
if(IS_PLAYING)
for( var i = 0; i < TOTAL_FRAMES; i++ )
for( var j = 0, m = ds_list_size(topoList); j < m; j++ ) {
var node = topoList[| j];

View File

@ -83,7 +83,7 @@ function Node_Particle(_x, _y, _group = noone) : Node_VFX_Spawner_Base(_x, _y, _
if(CURRENT_FRAME == 0) {
reset();
reLoop();
if(IS_PLAYING) reLoop();
}
if(IS_PLAYING) runVFX(frame);

View File

@ -501,7 +501,7 @@ function Panel_Inspector() : PanelContent() constructor {
var togl = array_safe_get(jun_disp, 2, noone);
if(togl != noone) var toging = _inspecting.getInputData(togl);
var lbx = (togl != noone) * ui(36);
var lbx = (togl != noone) * ui(40);
var lbw = con_w - lbx;
var ltx = lbx + ui(32);