Posted: Sun Oct 21, 2007 10:32 pm Post subject: Scripted Camera
A scripted camera is just a camera created in Actionscript that follows the mouse wherever it goes. It can be confusing at first, so I put in comments to explain some of the code.
Paste this code on the timeline:
Code:
createEmptyMovieClip("boxCam", 1000);
//creates a Movie Clip called "boxCam" with a depth of 1000
with (boxCam) {
onLoad = function () {
CamX = _x;
CamY = _y;
//the x and y values of the MC "boxCam"
};
onEnterFrame = function () {
//this tells Flash to constantly continue the actions
_x = _root._xmouse-10;
_y = _root._ymouse-10;
//the x and y values of the mouse
CamX = CamX+(_x-CamX)/50;
//CamX is being toldc to add itself to its x - causing it to stay in place
//50 is telling how fast or slow the camera sould go. The larger the number, the slower it goes.
_root._x = Stage.width/2-CamX;
//tells the main stage x to split in half, and take away from the CamX variable that was defined to "stay still", making it follow the _xmouse.
CamY = CamY+(_y-CamY)/50;
_root._y = Stage.height/2-CamY;
};
}
Make sure that you draw something on the screen so that you can see the camera's movement. _________________
Sorry to bring up old posts, but I tried this and I'm having one problem with it. The camera is following the mouse, but it doesn't know when to stop. So the image continues to move on and I see the background. How can I make it stop and add a border?
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum