Howto: Self-fading / killing / modifying objects!
1 post • Page 1 of 1
Howto: Self-fading / killing / modifying objects!
I found that if you spawn objects that modify itself on the fly, they tend only to work one at a time...but now I found a workaround that should work for any dynamic, self-modifying objects:
now put the same code as below the comment into your laser:
onLaserHit := (e)=>{scene.my.summonBall(e.pos, [0, 0], 0, true, 0.05, 0.05, false, true, [0, 1, 0, 1], 100, 2)};
now the laser will spawn onHit and every single object will work!
have fun
btw i think density = NaN causes a memory leak, so be aware...
- Code: Select all
scene.my.summonBall := (b_pos, b_vel,b_collideSet, b_selfcollide, b_density, b_radius, b_cake, b_border, b_color, b_airFric, b_lifetime)=>{Scene.addCircle {
collideWater := false;
mark := sim.time;
color := {[b_color(0), b_color(1), b_color(2), 1-(((sim.time - mark) / b_lifetime))]};
drawCake := b_cake;
collideSet := b_collideSet;
pos := b_pos;
radius := b_radius;
density := {(sim.time - mark) < b_lifetime ? {b_density} : {NaN}};
heteroCollide := b_selfcollide;
velocity := b_vel;
drawBorder := b_border;
airFrictionMult := b_airFric;
opaqueBorders := false;
};
// redefine the onHit event of the triggering object here! e.g.:
onLaserHit := (e)=>{scene.my.summonBall(e.pos, [0, 0], 0, true, 0.05, 0.05, false, true, [0, 1, 0, 1], 100, 2)};
}
now put the same code as below the comment into your laser:
onLaserHit := (e)=>{scene.my.summonBall(e.pos, [0, 0], 0, true, 0.05, 0.05, false, true, [0, 1, 0, 1], 100, 2)};
now the laser will spawn onHit and every single object will work!
have fun
btw i think density = NaN causes a memory leak, so be aware...
- pixartist
- Posts: 65
- Joined: Wed Sep 02, 2009 5:30 pm
1 post • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 7 guests