00:00
00:00
B1KMusic
Hi. I make games and software. I'm not on NG much, but feel free to peruse my youtube and gitlab for interesting stuff.

Braden @B1KMusic

Age 29, Male

Programmer/Musician/

fish

Earth, Milky Way

Joined on 6/19/11

Level:
10
Exp Points:
948 / 1,110
Exp Rank:
69,450
Vote Power:
5.20 votes
Rank:
Police Sergeant
Global Rank:
8,626
Blams:
42
Saves:
1,040
B/P Bonus:
12%
Whistle:
Normal
Medals:
799

How to make a VCam purely out of script in only 4 lines of code (AS2)!

Posted by B1KMusic - July 31st, 2011


First, did you download VCam.as from my previous post?

Did you follow the instructions down to the letters?

good, Copy/paste the below script into a new flash document, and be amazed by how you just created a VCam that follows what ever object you decided to name "char" with no problem at all

The two most important lines are:

CAM = new VCam(cam), which creates the camera
and
onEnterFrame = function(){ CAM.Follow(cam,ch) }, which makes it follow "char"

you don't have to code out a movie clip, but it can look a bit bad if you have a big, whopping camera object sitting on the stage.

The four lines that are inbold are the ones that create the camera, the rest illustrates that it works

script:

//This is an example to help use and show the power of VCam.as
/***** START CAMERA *****/

this.createEmptyMovieClip("cam", 1);
cam.lineTo(550, 400);
CAM = new VCam(cam);
onEnterFrame = function () { CAM.Follow(cam, ch) }

/***** END CAMERA *****/
this.createEmptyMovieClip("ch", 2);
ch.attachMovie("char", char, 2);
ch._x = 550;
/*
1 make a movie clip, name it char
2 Right click it in the library and click 'Linkage'
3 check "Export for actionscript"
*/

explanation:

1 | //This is an example to help use and show the power of VCam.as
2 | /***** START CAMERA *****/
3 | this.createEmptyMovieClip("cam", 1);
4 | cam.lineTo(550, 400);
5 | CAM = new VCam(cam);
6 | onEnterFrame = function () { CAM.Follow(cam, ch) }
7 | /***** END CAMERA *****/
8 | this.createEmptyMovieClip("ch", 2);
9 | ch.attachMovie("char", char, 2);
10 | ch._x = 550;
11 | /*
12 | make a movie clip, name it char
13 | Right click it in the library and click 'Linkage'
14 | check "Export for actionscript"
15 | */

1 - emphasises the fact that this is an example

2 - helps document the code incase you need to tweak somehting and have 1000 lines of code

3 - creates an empty movie clip with no mass, no height, width, or anything

4 - draws a line from 0,0 to 550,400 (top left to bottom right), giving it height and width

5 - uses the class VCam(hope you followed the integration instructions) to classify the line as a camera

6 - Makes the camera follow "ch", to be defined later, 12 times a second

7 - Documentation, no real significance, See line 2

8 - creates another lifeless movieclip, this time with depth of 2 and name ch, the depth needs to be different, or it replaces the camera entirely and fucks up the whole movie

9 - attaches the movieclip in the library under the name "char"

10 - helps illustrate the fact the the camera IS, in fact, working

11-15 - instructions on how to make the char object


Comments

Comments ain't a thing here.