00:00
00:00
Newgrounds Background Image Theme

GasGrass just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Actionscript codes here!

390,048 Views | 7,981 Replies
New Topic

Response to Actionscript codes here! 2003-07-14 12:52:00


Now that i got the JMP and run actionscript down now i need to figure out how to get the guy to atk or watever.

Response to Actionscript codes here! 2003-07-15 00:31:47


HELP, im making a side scrolling platform game, and need help with the code, see it works fine on my computer cause flash goes in and finds the .txt files that have the coordinates of where to put the items from the engine, is there a way i can insert this level data into the code? so i can upload it? im using flash 5, but if u dont know 5 jsut give me MX cause i have it jsut havent upgraded. thx
also tell me about if its a platform, how do i make it so the character can have a shotgun and press space to shoot it, then if the bullet hits the enemy the enemy has an animation play that is it getting killed? and the bullet goes away? PLEASE HELP thx
-Joe

Response to Actionscript codes here! 2003-07-15 11:25:58


THIS STUFF IS CAPITAL AWESOME

Response to Actionscript codes here! 2003-07-15 15:27:22


I remember seeing a tutorial at Flashkit.com about how to make simple movment script and all that, but it also shows how to make gunfire so that might help.

Response to Actionscript codes here! 2003-07-16 12:53:20


Thanks guys.

Response to Actionscript codes here! 2003-07-18 09:08:45


onClipEvent (load) {
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)) {
} else {
this._x += moveSpeed;
}
} else if (Key.isDown(Key.UP)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true)) {
} else {
this._y -= moveSpeed;
}
} else if (Key.isDown(Key.DOWN)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true)) {
} else {
this._y += moveSpeed;
}
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true)) {
} else {
this._x -= moveSpeed;
}
}
}
onClipEvent (enterFrame) {
if (_root.player._x > 500) {
this._x -= 10;
tellTarget ("_root.walls") {
_x -= 10;
}
}
if (_root.player._x < 50) {
this._x += 10;
tellTarget ("_root.walls") {
_x += 10;
}
}
if (_root.player._y > 350) {
this._y -= 10;
tellTarget ("_root.walls") {
_y -= 10;
}
}
if (_root.player._y < 50) {
this._y += 10;
tellTarget ("_root.walls") {
_y += 10;
}
}
}

Response to Actionscript codes here! 2003-07-18 18:36:34


Hey guys I'm also makinga side-scrolling platformer,but I got the platform codes working alright, but I need help with enemies now(and no its not about them atacking you) I need them to walk around, If you played a mario game before then you know, how the enemies just walk around and stuff. I could animate them like that but then there are gonna be more probs like that, so if you know what I'm saying then can you help.

Response to Actionscript codes here! 2003-07-19 01:12:03


hey man where did you get that book

~James~

Response to Actionscript codes here! 2003-07-19 03:43:18


Does anybody know some good video game and actionscript tutorial sites other than flashkit.

Response to Actionscript codes here! 2003-07-19 12:18:29


Ok i was gone for a while and didn't post awnsers, sorry, but now Im back, and these unawnsered questions will be awsered by me!

1: Moving script: The player stops moving his feet.
_____________________________________________________
Label the player mc "character"
and where the animation of the moving feet is, add this script to the last frame of it:

tellTarget ("_root.character") {
gotoAndStop(1);
}

2: Wall Script:
_____________________________________________________

Remove your moving script and replace it with this:

onClipEvent (load) {
// Set the move speed
moveSpeed = 5;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)) {
} else {
this._x += moveSpeed;
_root.mask._x += moveSpeed;
}
// Move Right
} else if (Key.isDown(Key.UP)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true)) {
} else {
this._y -= moveSpeed;
}
// Move Up
} else if (Key.isDown(Key.DOWN)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true)) {
} else {
this._y += moveSpeed;
}
// Move Down
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true)) {
} else {
this._x -= moveSpeed;
}
// Move Left
}
}

Everything that should not be able to walk trough should be in 1 movieclip labelled walls

3: Zooming scope script:
_____________________________________________________
I have no clue how to make this...sorry

4: Preloader tutorial
_____________________________________________________

1) Make a dynamic text box (no text in it) and give it the variable: _root.percent
2) Make a movieclip of that textbox
3) Add this script to your movieclip:

onClipEvent (enterFrame) {
b_loaded = _root.getBytesLoaded();
b_total = _root.getBytesTotal();
percent = Math.round((b_loaded/b_total)*100);
}

This will work if you have used the NG loader also, if you dont use the NG loader, then you also have to do this:
4) Draw a play button
5) Label it: "play"
6) Also add this script to the movieclip that contains your dynamic text box:

onClipEvent (load) {
tellTarget ("_root.play") {
_visible = false;
}
}
onClipEvent (enterFrame) {
if (_root.percent>=100) {
tellTarget ("_root.play") {
_visible = true;
}
}
}

5: make a player attack!_____________________________________________________

In the player movieclip(it must be labelled "character") make a new frame and label it "attack" whitin that frame, make another movieclip, and whitin it, draw the attack animation. at the end of the attacking animation, add this script:

tellTarget ("_root.character") {
gotoAndStop(1);
}

and add this script to the player movieclip:

onClipEvent (enterFrame) {
if (Key.isDown(Key.CONTROL)) {
tellTarget ("_root.character") {
gotoAndStop("attack");
}
}
}

you can attack by pressing CRTL

And sum1 asked for good actionscript sites:
acionscript.org
NG BBS

Keep posting guyz
Keep Asking questions

~EviLudy

(Click my profile :D)


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-19 15:26:29


Man this sux I guess no one knows how to make a enemy just walk around, How come all my questions never get answerred, For god's sake It shouldnt be that hard to make a chracter walk around on the screen.

Response to Actionscript codes here! 2003-07-19 15:47:05


Thanx alot eviLudy.

Response to Actionscript codes here! 2003-07-19 16:02:25


At 7/19/03 03:26 PM, Freek_Sk8er wrote: Man this sux I guess no one knows how to make a enemy just walk around, How come all my questions never get answerred, For god's sake It shouldnt be that hard to make a chracter walk around on the screen.

It depends on how your game is, is it top viewed or a 2d platformer?

Here's a 2D platformer script:

keep moving to right:

onClipEvent (enterFrame) {
this._x += speed;
}
onClipEvent (load) {
speed=10;
}

Keep moving to left:
onClipEvent (enterFrame) {
this._x -= speed;
}
onClipEvent (load) {
speed=10;
}

Move right, and then left and again:

onClipEvent (load) {
speed=8;
xposi =0;
}
onClipEvent (enterFrame) {
if (_root.xpts < 20) {
this._x += speed;
_root.xpts += 1;
}
}
onClipEvent (enterFrame) {
if (_root.xpts >= 20) {
this._x -= speed;
this._x -= speed;
_root.xposi -= 1;
}
if (_root.xposi <= -20) {
_root.xpts=0;
_root.xposi =0;
}
}

I hope ur happy now
=D


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-19 16:58:35


At 7/19/03 03:26 PM, Freek_Sk8er wrote: For god's sake It shouldnt be that hard to make a chracter walk around on the screen.

hmmmm, if its not that hard then do it yourself instead of asking people to do it for you.


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-07-20 02:40:31


At 7/19/03 04:58 PM, Star_Cleaver wrote:
At 7/19/03 03:26 PM, Freek_Sk8er wrote: For god's sake It shouldnt be that hard to make a chracter walk around on the screen.
hmmmm, if its not that hard then do it yourself instead of asking people to do it for you.

It doesnt matter if they ask me, if your not so good at AS it takes a real good while to find out how it must be made, i was bad with AS some time ago. And if I don't know somthing they ask, I try to make, then I learn from it myself...


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-20 05:32:55


Make an RPG game, like final fantasy 6:

1) make the character, make him a movieclip and label him: "player"

2) Draw a labyrinth of walls, convert it to movieclip and label it: "walls"

3) At the end of the labyrinth, draw a staircase, that takes you to the next level, convert it to movieclip and label it: "staircase1"

4) Add this script to your player (includes moving, stopping at walls, scrolling, and taking you to the next frame if your player collides with the staircase)

onClipEvent (load) {
// Set the move speed
moveSpeed = 10;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
if (_root.Walls.hitTest(getBounds(_root).xMax, _y, true)) {
} else {
this._x += moveSpeed;
}
// Move Right
} else if (Key.isDown(Key.UP)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMin, true)) {
} else {
this._y -= moveSpeed;
}
// Move Up
} else if (Key.isDown(Key.DOWN)) {
if (_root.Walls.hitTest(_x, getBounds(_root).yMax, true)) {
} else {
this._y += moveSpeed;
}
// Move Down
} else if (Key.isDown(Key.LEFT)) {
if (_root.Walls.hitTest(getBounds(_root).xMin, _y, true)) {
} else {
this._x -= moveSpeed;
}
// Move Left
}
}
onClipEvent (enterFrame) {
if (_root.player._x > 500) {
this._x -= 10;
tellTarget ("_root.walls") {
_x -= 10;
tellTarget ("_root.staircase1") {
_x -= 10;
}
}
}
if (_root.player._x < 50) {
this._x += 10;
tellTarget ("_root.walls") {
_x += 10;
tellTarget ("_root.staircase1") {
_x += 10;
}
}
}
if (_root.player._y > 350) {
this._y -= 10;
tellTarget ("_root.walls") {
_y -= 10;
tellTarget ("_root.staircase1") {
_y -= 10;
}
}
}
if (_root.player._y < 50) {
this._y += 10;
tellTarget ("_root.walls") {
_y += 10;
tellTarget ("_root.staircase1") {
_y += 10;
}
}
}
if (_root.player.hitTest(_root.staircase1)) {
tellTarget ("/") {
nextFrame();
}
}
}

5) For some levels, there should be a "random encounter" so that you can fight enemies. Here's a long script for it (I s'pose it should be able to be esier, this is just a script of an old game of mine that i didn't finish...)

onClipEvent (enterFrame) {
_root.xposi = _root.player._x;
_root.yposi = _root.player._y;
_root.fightframe = _currentframe;
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.RIGHT)) {
_root.battlenow = Math.floor(1+Math.random()*26);
switch (_root.battlenow) {
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
break;
case 8 :
break;
case 9 :
break;
case 10 :
break;
case 11 :
break;
case 12 :
break;
case 13 :
break;
case 14 :
break;
case 15 :
break;
case 16 :
break;
case 17 :
break;
case 18 :
break;
case 19 :
break;
case 20 :
break;
case 21 :
break;
case 22 :
break;
case 23 :
break;
case 24 :
break;
case 25 :
break;
case 26 :
stopAllSounds();
tellTarget ("/") {
gotoAndStop("Game", "slime-fight");
}
break;
default :
}
}
if (Key.isDown(Key.LEFT)) {
_root.battlenow = Math.floor(1+Math.random()*26);
switch (_root.battlenow) {
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
break;
case 8 :
break;
case 9 :
break;
case 10 :
break;
case 11 :
break;
case 12 :
break;
case 13 :
break;
case 14 :
break;
case 15 :
break;
case 16 :
break;
case 17 :
break;
case 18 :
break;
case 19 :
break;
case 20 :
break;
case 21 :
break;
case 22 :
break;
case 23 :
break;
case 24 :
break;
case 25 :
break;
case 26 :
tellTarget ("/") {
gotoAndStop("Game", "slime-fight");
stopAllSounds();
}
break;
default :
}
}
if (Key.isDown(Key.UP)) {
_root.battlenow = Math.floor(1+Math.random()*26);
switch (_root.battlenow) {
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
break;
case 8 :
break;
case 9 :
break;
case 10 :
break;
case 11 :
break;
case 12 :
break;
case 13 :
break;
case 14 :
break;
case 15 :
break;
case 16 :
break;
case 17 :
break;
case 18 :
break;
case 19 :
break;
case 20 :
break;
case 21 :
break;
case 22 :
break;
case 23 :
break;
case 24 :
break;
case 25 :
break;
case 26 :
tellTarget ("/") {
gotoAndStop("Game", "slime-fight");
stopAllSounds();
}
break;
default :
}
}
if (Key.isDown(Key.DOWN)) {
_root.battlenow = Math.floor(1+Math.random()*26);
switch (_root.battlenow) {
case 1 :
break;
case 2 :
break;
case 3 :
break;
case 4 :
break;
case 5 :
break;
case 6 :
break;
case 7 :
break;
case 8 :
break;
case 9 :
break;
case 10 :
break;
case 11 :
break;
case 12 :
break;
case 13 :
break;
case 14 :
break;
case 15 :
break;
case 16 :
break;
case 17 :
break;
case 18 :
break;
case 19 :
break;
case 20 :
break;
case 21 :
break;
case 22 :
break;
case 23 :
break;
case 24 :
break;
case 25 :
break;
case 26 :
tellTarget ("/") {
gotoAndStop("Game", "slime-fight");
stopAllSounds();
}
break;
default :
}
}
}


To have the random encounter working, the scene name, where the frame of the battle is must be labelled "game" and the frame where the fight is must be labelled "slime-fight"(it was a slimy monster in my game.)

So whatya think of this script? Pretty big i'd say =)

-Keep posting
-Keep Asking

~EviLudy


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-20 11:58:27


First off, I want to say this topic is great. It helped me out a lot.

I am making a game which includes a shooting game. I made the game with 3 enemies each with their own health bar. And I made it so when all 3 are dead the game is over, you win. But right now they all shoot at the same time, since it is an animation. I would like to know how do I make them each hide behind an obstacle and pop up at random times to shoot?

I also want to know how to make it so when each dies a health powerup appears that will re-fill the health bar. I tried but when I click the health bar it doesn't do anything.

And, one more thing. I looked at the random appearance script on the first page of the topic...it was good but if I make an animation of a guy appearing, attacking, then disappearing...is there any way to make him appear in random spots but it will always play the animation. Like when I tried it was doing the looping the animation as he shot all over the place. Thanks.

Response to Actionscript codes here! 2003-07-20 12:59:50


i was reading onhttp://www.spikything.com that there is a script for lips sync... any help plz

Response to Actionscript codes here! 2003-07-20 13:03:56


At 7/20/03 12:59 PM, isthatlegal wrote: i was reading onhttp://www.spikything.com that there is a script for lips sync... any help plz

a script for lips sync!?!?
Never heard about i. Ill do my best...


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-20 13:17:03


At 7/20/03 01:03 PM, eviLudy wrote: a script for lips sync!?!?
Never heard about i. Ill do my best...

dont trouble yourself. I'm pretty sure that Flash doesn't have the capabilities to read music in that way. Maybe isthatlegal is thinking of anohter program?


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-07-20 13:41:58


At 7/20/03 01:17 PM, Star_Cleaver wrote: dont trouble yourself. I'm pretty sure that Flash doesn't have the capabilities to read music in that way. Maybe isthatlegal is thinking of anohter program?

Well i have read much about attatchsound, setpan, getpan and that stuff but it seems impossible so i gave up hope.


Swing a Little more!

.. ROCK OUT!

BBS Signature

Response to Actionscript codes here! 2003-07-20 21:37:23


OK, since not any of my questions have been answered I'll go ahead and ask one maybe not so hard. I'm using version 5, but I think some of the MX codes might work so here it is: How can I make it so that when you jump under a platform and hit it on the bottom, then you cant pass throung it. is this a too hard question for you guys, or are you just gonna ignore me, like half the time.

Response to Actionscript codes here! 2003-07-20 22:55:10


I need to so when you shoot an enemy (just like a first person shoot.)(Like a crosshair and everything) after it plays a movie of him dying, I want it to goto a certain part of my movie.

Let my try to explain better. Ok. There is a guy on frame one. He is a movieclip/button. The frame sits still until you shoot him. when you shoot him, the movie clip plays a movie of him dying. Now what I want to do is after you shoot him, two arrows appear on the main timeline. So, in other words, when you shoot the guy, it goes to a clip of him dying, followed by 2 arrows popping on the screen. Help wiould be great. Thanks.

Response to Actionscript codes here! 2003-07-20 23:28:01


evil ludy, how do you make a simple wall collision effect?

Response to Actionscript codes here! 2003-07-20 23:37:25


Ludy, Im gonna add you to my favorite artist, just because youve helped me a lot with a lot of my problems. Thanks.

Response to Actionscript codes here! 2003-07-20 23:53:35


At 7/20/03 11:28 PM, negativeclock wrote: evil ludy, how do you make a simple wall collision effect?

Well, what do you want to do? To do collisions use hitTest.


I could surely die

If I only had some pie

Club-a-Club Club, son

BBS Signature

Response to Actionscript codes here! 2003-07-21 00:23:58


I know how to make the person, bu i want to make it that when you collide with a wall, you stop.

Response to Actionscript codes here! 2003-07-21 01:15:19


Oh yea, dont worry about my post. (about the game) Me and Pika Explorer got it figured out. If you have the script for colliding with a wall, which you probably do (included in script most of the time) Just make a square, or whatever, and turn it into a movie clip. Then, give it the instance name of "wall" (or whatever its called. In the script, like i said)

Response to Actionscript codes here! 2003-07-21 01:19:25


****PikaExploder

not again.. *rolls eyes*

Response to Actionscript codes here! 2003-07-21 01:26:26


At 7/21/03 01:19 AM, PikaExploder wrote: ****PikaExploder

not again.. *rolls eyes*

Dammit! I couldnt see your name, so I just took the best guess. I thought it was Pica Explorer, but I said Pika explorer. I was still wrong, but i spelled pika right! sorry..