color=skycolor and sim.time
9 posts • Page 1 of 1
color=skycolor and sim.time
I need some help changing the colour of the big white box in this scene
[scene]33509[/scene] to match the colour of the circles in the background changer.
i.e. I need the white box to be the same color as the background as the background changes.
I've tried putting this on the box but doesn't work
--------------------------------------------
What script would I need to make a spawned object delete after it has been in the scene x amount of sim.time
any help is greatly appreciated
this is part of a lager project to remake
and could someone explain why the above scene doesn't work in algodoo
[scene]33509[/scene] to match the colour of the circles in the background changer.
i.e. I need the white box to be the same color as the background as the background changes.
I've tried putting this on the box but doesn't work
(e)=>{e.this.color=app.background.skycolor}
--------------------------------------------
What script would I need to make a spawned object delete after it has been in the scene x amount of sim.time
any help is greatly appreciated
this is part of a lager project to remake
and could someone explain why the above scene doesn't work in algodoo
Newbie Thymer
Intermediate Phuner
Intermediate Phuner
- Cs24
- Posts: 41
- Joined: Tue Nov 03, 2009 5:30 am
Re: color=skycolor and sim.time
You were very close with the first scene! Instead of using onCollide to change the color put {app.background.skyColor}
As for the delete after a set amount of time look at this scene.
Timer script:
Spawn script:
In the timer script you can change the "2" after the >= sign to however long you want it to wait.
As for the delete after a set amount of time look at this scene.
Timer script:
- Code: Select all
(e)=>{
sim.time - e.this.controllerAcc >= 2 ? { Scene.my.deleteDensity = 0; e.this.controllerAcc = sim.time } : {Scene.my.deleteDensity = 2} }
Spawn script:
- Code: Select all
(e)=>{
scene.addCircle({ radius := 1; density := {Scene.my.deleteDensity}; restitution := 0.5; friction := 0.5; color := [0, 0, 0, 0.5]; vel := [0, 0]; pos := App.mousePos }) }
In the timer script you can change the "2" after the >= sign to however long you want it to wait.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: color=skycolor and sim.time
standardtoaster wrote:
- Code: Select all
(e)=>{
sim.time - e.this.controllerAcc >= 2 ? { Scene.my.deleteDensity = 0; e.this.controllerAcc = sim.time } : {Scene.my.deleteDensity = 2} }
Could you explain this code I do not really understand it. I get the if statement but i don't get why this works
-
niffirg1 - Posts: 376
- Joined: Mon Aug 31, 2009 10:31 pm
- Location: The Great American South!
Re: color=skycolor and sim.time
I put that script into a beacon so that it is constantly checking. I take the current simulation time and store it in the controllerAcc of the object. I continuously subtract the current simulation time with the controlerAcc and check if it greater than or equal to the set delete time. Once it reaches the delete time it sets the variable, scene.my.deleteDensity, to zero. I have another beacon in the scene with a similar script that will spawn a circle with the density of {scene.my.deleteDensity}. Once it reaches the delete time it will 'reset' the circle's controllerAcc to the simulation time. If it hasn't reached the delete time yet it keeps scene.my.deleteDensity at a constant value of 2. Now do you understand?
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: color=skycolor and sim.time
Thanks standardtoaster for the quick rply!
so any idea why RaRamalum's life scene doesn't work in algodoo?
or a way to get to delete objects with the timer in phun
and the delete only works with the newest spawned circle
(either or, I just need one other two to work)
edit: adding timer to raramalum's "animals" is going to be fun.....
so many things to fix
so any idea why RaRamalum's life scene doesn't work in algodoo?
or a way to get to delete objects with the timer in phun
and the delete only works with the newest spawned circle
(either or, I just need one other two to work)
edit: adding timer to raramalum's "animals" is going to be fun.....
so many things to fix
Last edited by Cs24 on Fri Nov 13, 2009 6:08 am, edited 1 time in total.
Newbie Thymer
Intermediate Phuner
Intermediate Phuner
- Cs24
- Posts: 41
- Joined: Tue Nov 03, 2009 5:30 am
Re: color=skycolor and sim.time
I don't know why it doesn't work in Algodoo. I'll look into it but I think that RaRaMalum would be more suited for it, as it is his scene.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: color=skycolor and sim.time
and where do I put {app.background.skyColor}, if not in OnCollide?
edit: thanks (to below)
edit: thanks (to below)
Last edited by Cs24 on Fri Nov 13, 2009 6:45 am, edited 1 time in total.
Newbie Thymer
Intermediate Phuner
Intermediate Phuner
- Cs24
- Posts: 41
- Joined: Tue Nov 03, 2009 5:30 am
Re: color=skycolor and sim.time
Sorry I didn't tell you. Put it in the color section of the script window.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
Re: color=skycolor and sim.time
standardtoaster wrote:I don't know why it doesn't work in Algodoo. I'll look into it but I think that RaRaMalum would be more suited for it, as it is his scene.
I know why it doesn't work. It has a backwards e.normal. If you want me to I can upload the fixed scene unless RaRaMalum wants to update it.
-
standardtoaster - Posts: 606
- Joined: Mon Aug 31, 2009 7:57 pm
9 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 8 guests