There is many ways to do it.
1. You can use function that I've madePut the following code to Global Code, name it like View Moving, and then click add.
- Code: Select all
void ViewFollowActor(char*name, int Fx, int Fy, int speed)
{
Actor*actor=getclone(name);
int X=view.width/2;
int Y=view.height/2;
if(x+X<actor->x-speed && actor->xscreen>xscreen+X+Fx)
{
x+=speed;
}
if(x+X>actor->x+speed && actor->xscreen<xscreen+X-Fx)
{
x-=speed;
}
if(y+Y<actor->y-speed && actor->yscreen>xscreen+Y+Fy)
{
y+=actor->yvelocity;
}
if(y+Y>actor->y+speed && actor->yscreen<xscreen+Y-Fy)
{
y-=speed;
}
}
And then use it in view - draw actor - script editor:
- Code: Select all
ViewFollowActor("Player", 50, 50, 5);
This means that view follows actor called Player if he is 50 pixels away from the middle of the screen in x axel and also in y axel.
And the last number is for how fast view will follow actor. Put in it the same value as your player runs. Y axel will follow automatically your
actors yvelocity.
2. You can use wire frame regionsPlace wire frame regions like this and main actor in the middle of them:
Make all regions as separate actors. Name them like: left, right, up, down.
Now go to main actor - collision - any side of - left - repeat: yes - script editor:
- Code: Select all
view.x -= 5; //Change 5 to be same as the speed your main actor runs
Same for collision any side of right, but put in script editor:
- Code: Select all
view.x +=5;
And for going up, ýou can use:
- Code: Select all
view.y -= 5;
And for going down, 'cause we have gravity, use this:
- Code: Select all
y += Player.yvelocity;
There is also other ways, but these are most simpliest to use.
Hope this helps!