view problem

Non-platform specific questions.

view problem

Postby raminkhan » Thu Mar 01, 2012 7:37 am

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

Re: view problem

Postby skydereign » Thu Mar 01, 2012 8:31 am

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

Re: view problem

Postby phyzix5761 » Thu Mar 08, 2012 8:34 am

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.
phyzix5761
 
Posts: 261
Joined: Sun Feb 27, 2011 4:28 am
Score: 18 Give a positive score

Re: view problem

Postby skydereign » Thu Mar 08, 2012 6:27 pm

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.
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