Be a Supporter!

Simple AS help

  • 283 Views
  • 9 Replies
New Topic Respond to this Topic
Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Simple AS help 2009-03-29 16:54:34 Reply

Hey, I'm making a platform style game (my 1st so I'm having a little trouble) and at the moment, I'm having trouble with movement. The player is not showing the animation for standing still when it stops jumping or moving, and instead, stops at the frame showing the last action.

If it would help find the problem, let me know and I'll post the AS

Thanks
-H


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato

SK8ninja
SK8ninja
  • Member since: Aug. 8, 2008
  • Offline.
Forum Stats
Member
Level 08
Blank Slate
Response to Simple AS help 2009-03-29 16:56:01 Reply

"Simple AS help"

Exactly what I'm looking for.


Suck it.

Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 16:57:41 Reply

Oh, and I'm using actionscript 2 on Flash MX 2004 Professional (Don't know if it Matters)

-H


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato

Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 17:48:52 Reply

At 3/29/09 04:56 PM, SK8ninja wrote: "Simple AS help"

Exactly what I'm looking for.

I hope you realize how remarkably unhelpful that was.


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato

FortressRubbish
FortressRubbish
  • Member since: Jan. 31, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 17:57:07 Reply

if you're using the "if" statement, be sure to use "else" in conjunction with it.

onClipEvent(enterFrame){
if( Key.isDown(Key.RIGHT)){
gotoAndstop(1);
}else{
gotoAndStop(2);
}
}

in the case stated, frame 1 is where the moving animation would be, frame two where the idle animation is located.

UnknownFury
UnknownFury
  • Member since: Aug. 10, 2005
  • Offline.
Forum Stats
Member
Level 26
Programmer
Response to Simple AS help 2009-03-29 18:10:17 Reply

We can't help unless you show us your code.

Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 18:46:22 Reply

Heres the Code
-H


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato

Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 18:59:20 Reply

Sorry, HERE is the right one.


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato

CompleteDouche
CompleteDouche
  • Member since: Dec. 1, 2008
  • Offline.
Forum Stats
Member
Level 09
Musician
Response to Simple AS help 2009-03-29 20:15:59 Reply

y don't u just go to actions and copy +paste code?


No matter what your weaknesses are, make sure your own abilities supersede them.

Hazmburk
Hazmburk
  • Member since: Mar. 28, 2009
  • Offline.
Forum Stats
Member
Level 02
Blank Slate
Response to Simple AS help 2009-03-29 20:50:20 Reply

I was under the impression that lengthy a code/post was obnoxious and frowned upon. Here goes:

onClipEvent (load) {
var speed:Number = 0;
var walk:Number = 3;
var run:Number = 6;
var grav:Number = 0;
var falling:Number = 0;
var jumped:Boolean = false;
var jumpHeight:Number = 25;
var touchingGround:Boolean = false;
var scale:Number = _xscale;
var doorOpened:Boolean = false;
var attacked:Boolean = false;
}
onClipEvent (enterFrame) {
if (!touchingGround ) {
grav++;
this._y += grav;
} else {
grav = 0;
}
if (_root.ground.hitTest(_x, _y, true)) {
touchingGround = true;
} else {
touchingGround = false;
}
if (!attacked) {
if (Key.isDown(65)) {
_x -= speed;
this.gotoAndStop(2);
_xscale = -scale;
} else {
gotoAndStop(1);
}
if (Key.isDown(68)) {
_x += speed;
this.gotoAndStop(2);
_xscale = +scale;
} else {
gotoAndStop(1);
}
if (Key.isDown(Key.SHIFT)) {
speed = run;
} else {
speed = walk;
}
}
}
onClipEvent (enterFrame) {
if (!attacked) {
if (jumped) {
falling += 0.5;
_y += falling;
if (touchingGround) {
jumped = false;
}
} else {
if (Key.isDown(87)) {
jumped = true;
falling = -jumpHeight;
this.gotoAndStop(3);
}
}
}
if ((Key.isDown(87)) and (Key.isDown(65))) {
this.gotoAndStop(3);
}
if ((Key.isDown(87)) and (Key.isDown(68))) {
this.gotoAndStop(3);
}
if ((!Key.isDown(87)) and (!touchingGround)) {
this.gotoAndStop(3);
} else if ((Key.isDown(87)) and (!touchingGround)) {
this.gotoAndStop(3);
}
if ((_currentframe == 3) and (touchingGround)) {
gotoAndStop(1);
}
}
onClipEvent (keyUp) {
gotoAndStop(1);
}
onClipEvent (enterFrame) {
if (this.hitTest(_root.enemy)) {
_root.hp.health-1;
}
}


We can easily forgive a child who is afraid of the dark; the real tragedy of life is when men are afraid of the light.
-Plato