Again a View Question

Non-platform specific questions.

Again a View Question

Postby raminkhan » Mon Dec 26, 2011 10:03 pm

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.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Again a View Question

Postby skydereign » Mon Dec 26, 2011 10:45 pm

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)");
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Again a View Question

Postby raminkhan » Tue Dec 27, 2011 12:15 am

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.
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Again a View Question

Postby schnellboot » Tue Dec 27, 2011 1:39 am

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;
schnellboot
 
Posts: 819
Joined: Sat Mar 31, 2007 1:35 pm
Location: Germany
Score: 102 Give a positive score

Re: Again a View Question

Postby raminkhan » Tue Dec 27, 2011 4:18 am

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?
raminkhan
 
Posts: 63
Joined: Mon Sep 12, 2011 3:35 pm
Score: 0 Give a positive score

Re: Again a View Question

Postby skydereign » Tue Dec 27, 2011 6:28 am

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");
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest