[Help] "FOR" function
12 posts • Page 1 of 1
[Help] "FOR" function
hi, its me again
can anyone could tell me how "for" works on algodoo?? i want to ask just 2 time "if" function.. so how to it?
can anyone could tell me how "for" works on algodoo?? i want to ask just 2 time "if" function.. so how to it?
- daniel1296
- Posts: 15
- Joined: Fri Dec 30, 2011 9:31 pm
Re: [Help] "FOR" function
Buil-in "for":
It's function for(n, what) with 2 arguments:
1) integer - number of iteration
2) function - function which you need to call few times with one argument - number of call
Example:
scene.my.show = (i) => {scene.addbox({pos := [i,0]; text := (""+ i)})};
for(5, scene.my.show);
It's function for(n, what) with 2 arguments:
1) integer - number of iteration
2) function - function which you need to call few times with one argument - number of call
Example:
scene.my.show = (i) => {scene.addbox({pos := [i,0]; text := (""+ i)})};
for(5, scene.my.show);
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: [Help] "FOR" function
...and here it is post with extended for cycle example: viewtopic.php?f=13&t=5146&p=54364&hilit=xfor#p54364
Dream of Algodoo as game development engine...
-
Kilinich - [Best bug reporter 2010]
- Posts: 2098
- Joined: Mon Aug 31, 2009 8:27 pm
- Location: South Russia
Re: [Help] "FOR" function
umm.. its not working to me. i did "scene.my.show = (i) => {_____};" in the console ("__" its addpolygon and a lot of things);
and in the polygon i did "for(2, scene.my.show)" and nothing happend... i tired this function without "for" and its working. help plz
and in the polygon i did "for(2, scene.my.show)" and nothing happend... i tired this function without "for" and its working. help plz
- daniel1296
- Posts: 15
- Joined: Fri Dec 30, 2011 9:31 pm
Re: [Help] "FOR" function
You need to write it in the oncollide(e)>{......} and onlaserhit(e)>{......} entry boxes of a geometry.
Console is used for creating scene.my variables most of the time
Console is used for creating scene.my variables most of the time
-
Nxdt - Posts: 1019
- Joined: Mon Aug 31, 2009 6:32 pm
- Location: Scotland!
Re: [Help] "FOR" function
i want to do when box hit something a polygon will appear only once! You can upload a scene that does this?
(sorry for my english)
(sorry for my english)
- daniel1296
- Posts: 15
- Joined: Fri Dec 30, 2011 9:31 pm
Re: [Help] "FOR" function
Appear, as in become visible, like you can see it? Or spawn it once.
-
Nxdt - Posts: 1019
- Joined: Mon Aug 31, 2009 6:32 pm
- Location: Scotland!
Re: [Help] "FOR" function
Oncollide code, make sure the code will delete the original objects (The one that has the code) script, so it can't spawn the polygon again.
-
Nxdt - Posts: 1019
- Joined: Mon Aug 31, 2009 6:32 pm
- Location: Scotland!
Re: [Help] "FOR" function
no.. cant do that. i build a beyblade game, and i want to do that when hp < 100 a special gem will spwan once. any idea?
- daniel1296
- Posts: 15
- Joined: Fri Dec 30, 2011 9:31 pm
Re: [Help] "FOR" function
I don't really understand why you would want to spawn a special "gem". If you want to make your beyblade faster or something, this can be done in the health bar script.
I assume you also need help with the health code.
Basically, create a "scene.my.hp1 = x" (x is just a number) variable, in the console, this will record the "Hp" of player 1 say. And everytime a collision happens it lowers the hp.
I did a little health example, it also spawns a gem once, and when the hp gets lower than 100.
I assume you also need help with the health code.
Basically, create a "scene.my.hp1 = x" (x is just a number) variable, in the console, this will record the "Hp" of player 1 say. And everytime a collision happens it lowers the hp.
I did a little health example, it also spawns a gem once, and when the hp gets lower than 100.
- Attachments
-
- HP Demo.phz
- HP demo
- (25.63 KiB) Downloaded 174 times
-
Nxdt - Posts: 1019
- Joined: Mon Aug 31, 2009 6:32 pm
- Location: Scotland!
Re: [Help] "FOR" function
i have hp function.. u can download the scene and look. it is with a sin function..
and i found another way to do gem.. 10x a lot guys for helping.
(sorry for my bad english)
and i found another way to do gem.. 10x a lot guys for helping.
(sorry for my bad english)
- daniel1296
- Posts: 15
- Joined: Fri Dec 30, 2011 9:31 pm
12 posts • Page 1 of 1
Who is online
Users browsing this forum: No registered users and 15 guests