View previous topic :: View next topic |
Author |
Message |
mike
Joined: 28 Dec 2008 Posts: 34
|
Posted: Sun Dec 28, 2008 8:09 pm Post subject: removeStaticShape Work? |
|
|
I created a static shape and eventually during the simulation i want to remove it so i call space.removeStaticShape(shape) but the static shape is still there in the simulation.
In the documentation it says
void removeStaticShape (GeometricShape shape);
Remove shape from simulation
Do i have to call something else with that?
Im using the rc1phobos version. |
|
Back to top |
|
|
mike
Joined: 28 Dec 2008 Posts: 34
|
Posted: Mon Dec 29, 2008 8:35 pm Post subject: |
|
|
Ok maybe it does work if i do removeStaticShape(space.shapes[0]); but i found that it will just delete all the static shapes not just one of them. |
|
Back to top |
|
|
mike
Joined: 28 Dec 2008 Posts: 34
|
Posted: Tue Dec 30, 2008 12:39 pm Post subject: |
|
|
Ok this is my last post, i got a solution. Im still new to learning D so im not sure if theres an easier way. All i know is that an array.remove doesnt seem to remove the object from the array at least for me.
Heres my solution
I did have some code here but i have found out that all you would to need to add is Code: | shapes.length = shapes.length-1; | at the end of the function. I found that array.remove will put the element you wanted to remove to the end of the array but it will not change the length of the array causing all the shapes to still be there. |
|
Back to top |
|
|
brianguertin
Joined: 26 Dec 2008 Posts: 8
|
Posted: Tue Jan 06, 2009 1:42 pm Post subject: |
|
|
array.remove? i didnt think there was a standard function for that. I always use my own. |
|
Back to top |
|
|
mike
Joined: 28 Dec 2008 Posts: 34
|
Posted: Tue Jan 06, 2009 4:54 pm Post subject: |
|
|
Yeah. Its a nice add.
Its just like int myarray[4] = [1,2,3,4];
myarray.remove(1);
and that will remove the variable 1 from the list, well at least put it at the end of the array so it would look like [2,3,4,1] but then you can just easily change the length of the array to get rid of the variable one. |
|
Back to top |
|
|
SirAlaran
Joined: 19 Feb 2007 Posts: 84 Location: Silicon Valley
|
Posted: Thu Jan 08, 2009 2:27 pm Post subject: |
|
|
brianguertin wrote: | array.remove? i didnt think there was a standard function for that. I always use my own. |
There isn't a standard function for that. I think that the array removal stuff was in there because Mason was using Tango. When I ported Blaze to Phobos I wrote my own version of that function, but I think it was made obsolete in the newer versions of Blaze.
Tango's array documentation:
http://dsource.org/projects/tango/docs/current/tango.core.Array.html |
|
Back to top |
|
|
|