Page 1 of 1

Again a View Question

PostPosted: Mon Dec 26, 2011 10:03 pm
by raminkhan
Hi guys I was just wondering to know how can I make my view dedicated to a actor even if that actor is destroyed in certain point and again recreated due to some event?

let me give you an example: this is my ball: * ---> it goes and hits the wall and gets destroyed but few seconds later it gets cloned I want the view to follow this ball as it has before the ball hitted the wall.

Re: Again a View Question

PostPosted: Mon Dec 26, 2011 10:45 pm
by skydereign
If you are using parent as a way to have the view follow the actor, and there is only one ball actor created at a time, this will work.
ball -> Create Actor -> Script Editor
Code: Select all
ChangeParent("view", "Event Actor");

ball -> Destroy Actor -> Script Editor
Code: Select all
ChangeParent("view", "(none)");

Re: Again a View Question

PostPosted: Tue Dec 27, 2011 12:15 am
by raminkhan
Actually sky this didn't work, because for the first ball, view follows no problem but after the collision happens and I am trying to create the same ball as create actor, the view doesn't follow it.

Re: Again a View Question

PostPosted: Tue Dec 27, 2011 1:39 am
by schnellboot
the problem is that children dont go to the position of their parents they are just locked to them
so you should bring the view actor to the new created ball actor
in some way like
x=ball.x;
y=ball.y;

Re: Again a View Question

PostPosted: Tue Dec 27, 2011 4:18 am
by raminkhan
how can I tell the view to get the new x and y axis of new created object I mean is there any function in GE to allow the view to do that?

Re: Again a View Question

PostPosted: Tue Dec 27, 2011 6:28 am
by skydereign
You could use MoveTo which is a function, but it'd be unnecessary. This is what you want... when the ball actor is created, you want to move the view to the newly created ball. The ball actor has a create actor event already, and so you want to move the view there. So, just add the view movement...
ball -> Create Actor -> Script Editor
Code: Select all
view.x = x-view.width/2; // the -view.width/2 is used to make the new ball actor centered on screen
view.y = y-view.width/2;
ChangeParent("view", "Event Actor");