how to make the view follow the character

Non-platform specific questions.

how to make the view follow the character

Postby raminkhan » Sun Dec 18, 2011 4:45 am

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

Re: how to make the view follow the character

Postby Nykos » Sun Dec 18, 2011 5:45 am

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.
Nykos
 
Posts: 110
Joined: Sun Dec 19, 2010 11:11 pm
Score: 6 Give a positive score

Re: how to make the view follow the character

Postby foleyjo » Sun Dec 18, 2011 8:36 am

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
KISS -Keep It Simple Stoopid
foleyjo
 
Posts: 275
Joined: Mon Jul 09, 2007 1:15 pm
Score: 15 Give a positive score

Re: how to make the view follow the character

Postby Nykos » Sun Dec 18, 2011 9:53 am

i'll always be a padawan in scripting ... :)
Nykos
 
Posts: 110
Joined: Sun Dec 19, 2010 11:11 pm
Score: 6 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest