Page 1 of 1

view problem

PostPosted: Thu Mar 01, 2012 7:37 am
by raminkhan
My screen sticks with my character but the issue is that this code in draw actor of my view is not working properly


view.x= Player.x -(.001*view.width); this is not working because my character is always at the left edge of the screen and sticks there and wont move into the screen even when its moving.
view.x = max(view.x, -1);

Please help.

Re: view problem

PostPosted: Thu Mar 01, 2012 8:31 am
by skydereign
raminkhan wrote:view.x= Player.x -(.001*view.width);

That code wouldn't work because 0.001 * view.width is rather small, if you are using iphone res it is 0.48 pixels. For what you want you can use just one line of code (combines your two and fixes it).
Code: Select all
view.x = max(Player.x-view.width/2, -1);

Re: view problem

PostPosted: Thu Mar 08, 2012 8:34 am
by phyzix5761
If you want the view to follow the player at an offset try the following:

Code: Select all
view.x = player.x-someVar;



where someVar is the number you want to offset the view by.

Re: view problem

PostPosted: Thu Mar 08, 2012 6:27 pm
by skydereign
Which is exactly what the code I posted was, except that it puts a lower limit on how far the view can move back. All the max does is choose the larger number between them, meaning view.x can be no smaller than -1.