Welcome to Virtual Tutorial World Guest!



Scripted Camera

 
Post new topic   Reply to topic    VTW Forum Index -> Actionscript
View previous topic :: View next topic  
Author Message
computergeek67
Administrator
Administrator


Joined: 31 Jul 2007
Posts: 144


Tokens: 147
Location: US

PostPosted: Sun Oct 21, 2007 10:32 pm    Post subject: Scripted Camera Reply with quote

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



Come to me if you have any questions
Back to top
View user's profile Send private message Visit poster's website
revneil
Newbie
Newbie


Joined: 16 Jul 2008
Posts: 1


Tokens: 1


PostPosted: Wed Jul 16, 2008 11:00 pm    Post subject: Reply with quote

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?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    VTW Forum Index -> Actionscript All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2005 phpBB Group
Virtual Tutorial World ©2007-2008 computergeek67

Affiliates