Click here to Skip to main content
13,055,490 members (52,120 online)
Rate this:
Please Sign up or sign in to vote.
I am using a timer-based animation to animate three 3dobjects. I have used a dispatcher timer for this purpose, and within the timer task method I have called my 3Dobject creation method thrice. Right below that and within the same Timer task method I have included a set of statements that generates new position for the objects.
For example,

private void timertask(object sender, EventArgs e)
createsolid(x[0], y[0], z[0]); ->this creates the first cube w.r.t x,y,z positions
createsolid(x[1], y[1], z[1]);
createsolid(x[2], y[2], z[2]);
for(int i=0;i<4;i++)
x[i] = update_x[i];
y[i] = update_y[i];
z[i] = update_z[i];

So, everytime the timer is triggered(currently set to trigger 10 times a second), the cubes are created in a new updated position(very slow though). But the problem I face right now that I could not delete the cubes in old positions. Thus, it leaves a whole trail of cubes when the timer progresses. I want to delete the cube in old position when the cube is created for the new position. Or I would like to use some repaint method or something that just allows me to create the cubes just once and after that it should just allow me to move the cube according to the new positions generated in time.

Just one humbe request. I am a beginner and please go easy on me. I would greatly appreciate a striaght forward answer. Links are welcome too, but I don't need solutions in xaml. I am working completely on C#.

Posted 31-Aug-11 5:13am
Updated 31-Aug-11 7:19am

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

I'm guessing, but...

0) To delete/erase one, shouldn't you just be able to delete it form the parent group's Children collection?

1) To change it, retrieve it from the parent group's Children collection and change the appropriate values.
steersteer 31-Aug-11 11:37am
Thanks for your reply. I guess you are right too. I am trying to use "group.Children.Remove" or "group.Children.RemoveAt" at the end of my time_task method ? (how about group.Children[0].Remove for first cube). I honestly don't know how it works. Please give me a syntax or example to use them with in a method. would really appreciate it. thanks
I'm using the same resources that you would be - google. I have to look up each answer I give you. Children is a collection. It might be a collection of objects that themselves have collections. See if intellisense will guide you. Failing that, google is your friend. I don't generally hold people's hand - I'm more of a "shove 'em in the right direction" kinda person.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 31 Aug 2011
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100