Page 1 of 1

how to make the view follow the character

PostPosted: Sun Dec 18, 2011 4:45 am
by raminkhan
okay i got a character on screen is moving on x-axis but I want to be able to have the view and my top tool bar to follow the character i got a huge tile in length.

Re: how to make the view follow the character

PostPosted: Sun Dec 18, 2011 5:45 am
by Nykos
For the view, you have two ways.

The first would be making the player parent of view.

The second way is having a Draw Event in view with a code like this:
Code: Select all
view.x=player.x-(???)


replace the (???) by half the X size of your game. Ex: If your game is 480 x320, your X size is 480. 480 / 2 =240 so the code is this:
Code: Select all
view.x=player.x-240


Then for the the tool bar, just make it child of the view.

Re: how to make the view follow the character

PostPosted: Sun Dec 18, 2011 8:36 am
by foleyjo
Easier to just say
Code: Select all
view.x= player.x -(.5*view.width);


That way you can change the view size without worrying about changing this

Re: how to make the view follow the character

PostPosted: Sun Dec 18, 2011 9:53 am
by Nykos
i'll always be a padawan in scripting ... :)