Help Making Alerts
4 posts • Page 1 of 1
Help Making Alerts
- Code: Select all
alert = (a,b,c,d,e)=>{
//bcolor, bsize, bpos, btext, bdelay
Scene.addBox({
color := a; //bcolor
size := b; //bsize
pos := c; //bpos
text := d; //btext
collideSet := 1;
friction := Sim.time + e; //bdelay and simtime
body := 0;
drawBorder := {Sim.time > friction ? {density = 0} : {};true;};
});
};
This is my code for to make a box with some text in it, with a certain colour, at a certain position and with a certain size. It should also destroy itself after a certain amount of seconds using density=0.
- Normal attributes made.
Friction contains spawnTime + time allowed to appear for.
drawBorder contains code to check for expiration.
It doesn't work
When the box is spawned, it does NOT disapear after any amount of time. However, the box will disapear if I click on the drawBorder text box and press ENTER.
Any ideas??
Thanks for your help, phunHunger.
Noobs are the best 
-

phunHunger - Posts: 31
- Joined: Mon Apr 26, 2010 10:01 pm
Re: Help Making Alerts
the problem is you can't spawn objects with dynamic properties. it got discussed a few months ago and it's up to date again right now here in the thyme section. there's a workaround so that it gets dynamic by kilinich.
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322
but you can only make ONE property dynamic. that's the disadvantage. but it's definitely way better than nothing.
http://www.algodoo.com/forum/viewtopic.php?f=13&t=1322
but you can only make ONE property dynamic. that's the disadvantage. but it's definitely way better than nothing.

-

KarateBrot - Posts: 825
- Joined: Mon Aug 31, 2009 7:32 pm
- Location: Germany
It Works Now :)
- Code: Select all
alert = (a, b, c, d, e)=>{
(Scene.addBox{
color := a;
size := b;
pos := c;
text := d;
collideSet := 1;
body := 0;
}).density = eval("{Sim.time > "+ (Sim.time + e) +" ? {0} : {1};}");
};
This is the new code, it works well so far. I used a bit of eval so i didn't need two variables being used at the same time.
Thanks very much for your help
Noobs are the best 
-

phunHunger - Posts: 31
- Joined: Mon Apr 26, 2010 10:01 pm
4 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 5 guests



