View Full Version : Screen "following" the character
Ultimatepuff
03-12-2008, 09:27 PM
If I make a background larger than the actual flash movie (let's say the flash background size is 550x300, but I put a picture 800x600 into it), then what script must I put in to make the screen "follow" the character? As in, when the character is close to walking off the screen, then the background moves so the character is in the center.
Durnus
03-13-2008, 06:55 PM
Okay, with this simple of a background, this is easy. Instead of moving the player movieclip, just move the background in the opposite direction as the player would move.
In other words:
background.y += -(player.yvel);
This is the idea, but it wouldn't be quite as simple for a more complex game. Not hard, but not simple. You could/would store everything in a movie clip that scrolls opposite the player, and just put all the enemies and other stuff in that movie.
(Rereading your post I see your question differently, more of a zelda scrolling than a RPG scrolling. This would use the same concept, just with differnet maths and scrolls. There would also be optimizations and segmentation, but I'll save that for another post if you want me to continue.)
killingdyl
03-20-2008, 01:25 AM
if you want the screen to follow your char all the time you can try something like
...
_root.char._x += ......
_root._x -= ......
...
to make it move all the time just change the +/- to the opposite
if you want the screen to move when the char is almost off the stage you can add an "if" statement.
if(_root.char._x >= 500){
_root._x -= ........
hope this helps
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.