Post by thomas on Jan 12, 2006 0:15:11 GMT
FIRST note:This tutorial I originally made on Newgrounds for the real AS:Main,it is not stolen,and you may notice some stuff here about other posts in the specific thread.
(NOTE:All codes are made in the Action Script menu,press F9 on your keyboard to open it up)
I'm not one that could do to much with API,but I know I could explain the basic parts of it.This post might be short,but whatever.
Explaining API:API is mostly something people use to make KB games,which is trying to keep the KB file size low,which means that they don't use anything but coding,which is API.API can never be animated into a good full length movie(well,good that is...the longest your movie would be is less than 1 second)and is always used for games...most of the time.
EXAMPLE CODE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
endFill();
(copy+paste into first movie frame)-I know it's not a box even though it should be,but it doesn't matter.It's an API code.Lemme explain each code as best I can.
createEmptyMovieClip("t",2) - This creates the movieclip item.It also must start any code that you make in API,otherwise nothing happens.Where "t" is at is the name of the movieclip.In almost all API games,there are at least 2 empty movie clips.Name them well.2 is the depth of the object.I really don't know what this is for,so I just put 2 or 5 in.
lineStyle(5, 000000, 100) - This is creating the lineStyle of you object.The first number is the size of your line(0-10.This is your chance to see what a 100 sized line is like),the second number(or 6 numbers) is the RBG or RGB,whatever is is.When choosing a color for something,a fill,you'll notice the numbers at the top of the fill box(or line box).That 6 part number the RBG.000000 is black,FFFFFF is white,FF0000 is red.There are endless numbers.I usually use black for lines...ok,the last number is the alpha of the line.100 will make the object solid,any lower will make the object start disappearing.
beginFill(0xFF0000, 100) - This,as the code part says,is beginning the fill...as in fills in the object you make with a color.The first number,once again,is the RBG.notice how I added 0x before the number?I dunno if it's needed,but I had to to make the fill appear.The second number...(sigh)...is the alpha.Change it lower to make the object start disappearing.
lineTo(50, 0) - This is the part where your shape will start taking form.The first number is the X value of where the X line goes to.The second number is the same,but deals with Y.
EXAMPLE
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
This should make a square,but it isn't working,so instead you come out with a butterfly or something...REMEMBER that your object will always start in the top left hand corner.
endFill() - Simple.This will end the first object you make.A better way to say it is \it separates this objects edits from the other objects/
Now,this next part can be done 2 ways...it's for moving your object to where you want it at.
FIRST WAY
The first way you can do with is by using the moveTo code or whatever.
moveTo(0, 0) - This is sorta like lineTo,but instead,it moves the object to the X and Y value places.The first number is for moving the object to a selected X place,and the second number is moving it to the Y place.
EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
moveTo(345, 200);
endFill();
I can never get moveTo to work,but I'm pretty sure that this would be the code.
SECOND WAY
The second way is simple.It's just saying something like \_x = 300/ or something.
EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
_x = 225;
_y = 200;
endFill();
Notice how the object moved close to the center of the stage or something?I like to use this way better.
I know there are more ways to use API,but I can't figure any of them out.
Final note:With API,you can create platforms and stuff without to much trouble.It's mostly just adding the script to the objects edit and changing it a bit to make it work.When making a platform,however,you need to make another movieclip to be the platform.
(NOTE:All codes are made in the Action Script menu,press F9 on your keyboard to open it up)
I'm not one that could do to much with API,but I know I could explain the basic parts of it.This post might be short,but whatever.
Explaining API:API is mostly something people use to make KB games,which is trying to keep the KB file size low,which means that they don't use anything but coding,which is API.API can never be animated into a good full length movie(well,good that is...the longest your movie would be is less than 1 second)and is always used for games...most of the time.
EXAMPLE CODE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
endFill();
(copy+paste into first movie frame)-I know it's not a box even though it should be,but it doesn't matter.It's an API code.Lemme explain each code as best I can.
createEmptyMovieClip("t",2) - This creates the movieclip item.It also must start any code that you make in API,otherwise nothing happens.Where "t" is at is the name of the movieclip.In almost all API games,there are at least 2 empty movie clips.Name them well.2 is the depth of the object.I really don't know what this is for,so I just put 2 or 5 in.
lineStyle(5, 000000, 100) - This is creating the lineStyle of you object.The first number is the size of your line(0-10.This is your chance to see what a 100 sized line is like),the second number(or 6 numbers) is the RBG or RGB,whatever is is.When choosing a color for something,a fill,you'll notice the numbers at the top of the fill box(or line box).That 6 part number the RBG.000000 is black,FFFFFF is white,FF0000 is red.There are endless numbers.I usually use black for lines...ok,the last number is the alpha of the line.100 will make the object solid,any lower will make the object start disappearing.
beginFill(0xFF0000, 100) - This,as the code part says,is beginning the fill...as in fills in the object you make with a color.The first number,once again,is the RBG.notice how I added 0x before the number?I dunno if it's needed,but I had to to make the fill appear.The second number...(sigh)...is the alpha.Change it lower to make the object start disappearing.
lineTo(50, 0) - This is the part where your shape will start taking form.The first number is the X value of where the X line goes to.The second number is the same,but deals with Y.
EXAMPLE
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
This should make a square,but it isn't working,so instead you come out with a butterfly or something...REMEMBER that your object will always start in the top left hand corner.
endFill() - Simple.This will end the first object you make.A better way to say it is \it separates this objects edits from the other objects/
Now,this next part can be done 2 ways...it's for moving your object to where you want it at.
FIRST WAY
The first way you can do with is by using the moveTo code or whatever.
moveTo(0, 0) - This is sorta like lineTo,but instead,it moves the object to the X and Y value places.The first number is for moving the object to a selected X place,and the second number is moving it to the Y place.
EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
moveTo(345, 200);
endFill();
I can never get moveTo to work,but I'm pretty sure that this would be the code.
SECOND WAY
The second way is simple.It's just saying something like \_x = 300/ or something.
EXAMPLE
_root.createEmptyMovieClip("tt", 2);
lineStyle(5, 000000, 100);
beginFill(0xFF0000, 100);
lineTo(0, 50);
lineTo(50, 0);
lineTo(50, 50);
lineTo(0, 0);
_x = 225;
_y = 200;
endFill();
Notice how the object moved close to the center of the stage or something?I like to use this way better.
I know there are more ways to use API,but I can't figure any of them out.
Final note:With API,you can create platforms and stuff without to much trouble.It's mostly just adding the script to the objects edit and changing it a bit to make it work.When making a platform,however,you need to make another movieclip to be the platform.