loop script
14 posts • Page 1 of 1
loop script
Hello.He is trying to make a circle which dies and creates new same circle endlessly. My scrio in circle (e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
I can made it like x loop coping script like.
(e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
density := 2.0;
radius := 0.38
})
}
but i need infinite loop.
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
I can made it like x loop coping script like.
(e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{
Scene.addCircle({
timeToLive := 3;
collideSet := 1;
friction := 0.5;
color := [0.73151445, 0.55123925, 0.21842225, 1.0];
pos := [-0.84514439, 2.6246722];
onDie := (e)=>{};
density := 2.0;
radius := 0.38
})
}
density := 2.0;
radius := 0.38
})
}
but i need infinite loop.
- Attachments
-
- kopiowanienieskonczonosc.phz
- (5.38 KiB) Downloaded 101 times
- mistiqpiotr
- Posts: 7
- Joined: Tue Dec 15, 2015 5:06 pm
Re: loop script
Paste this code in the onDie event.
- Code: Select all
timeToLive = 3;
Scene.cloneEntityTo(e.this, Pos)
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: loop script
If the ball has to be spawned on position [-0.84514439, 2.6246722] you can write this code in the onDie event
You also have to remove the code that you have already written in the circle.
- Code: Select all
timeToLive = 3;
Scene.cloneEntityTo(e.this, [-0.84514439, 2.6246722])
You also have to remove the code that you have already written in the circle.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: loop script
what i if i wanna make it on group? like i have 2 circle in group and when one of it colide make another group with 2 circle?
- mistiqpiotr
- Posts: 7
- Joined: Tue Dec 15, 2015 5:06 pm
Re: loop script
ondie = (e)=>{
timetolive = 3;
scene.cloneEntityTo(e.this , pos1);
scene.cloneEntityTo(e.this , pos2)
}
timetolive = 3;
scene.cloneEntityTo(e.this , pos1);
scene.cloneEntityTo(e.this , pos2)
}
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: loop script
what doesnt work? does the object not reappear after dying? If you wrote the above code, the circle should create 2 clones when triggering the script. If you want it to clone on death, write it in OnDie, if you want it to clone when colliding, write it in OnCollide
- FRA32
- Posts: 229
- Joined: Wed Dec 03, 2014 9:51 pm
Re: loop script
scripts must be in first circle not on both
- mistiqpiotr
- Posts: 7
- Joined: Tue Dec 15, 2015 5:06 pm
Re: loop script
mistiqpiotr wrote:scripts must be in first circle not on both
I don't think that's possible, unless you know the ID of both circles.
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
Re: loop script
This code might work, although it's a kinda odd way to do it.
replace <id1> by the entityID of the other circle and <id2> by the entityID of the circle that runs the code
- Code: Select all
onCollide = (e)=>{
scene.cloneEntityTo(e.this, [-1, 1]);
scene.cloneEntityTo(scene.entityByID(<id1>), [1, 1])
}
update = (e)=>{
(scene.entityByID(<id1>)).onCollide = (e)=>{
scene.cloneEntityTo(e.this, [1, 1]);
scene.cloneEntityTo(scene.entityByID(<id2>), [-1, 1])
}
}
replace <id1> by the entityID of the other circle and <id2> by the entityID of the circle that runs the code
-
T'wind_ - Posts: 86
- Joined: Wed Jul 08, 2015 5:33 pm
- Location: Western Europe
14 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 0 guests