|
-
Help nig 13, jumpin sound
I need to know how to make it where my character jumps up with the arrow key, I need my character to make a sound, How do I do that?
im in flash 8
-
Prid - Outing
I already told you, you need to post the code you're using for the jumping part in order for me to implement the jumping sound
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
Client Software Programmer
Can't he just add the sound loop in one of the jumping keyframes?
-
 Originally Posted by Nig 13
I already told you, you need to post the code you're using for the jumping part in order for me to implement the jumping sound 
im sorry, here is my jumping code
onClipEvent (enterFrame) {
if (!attacked) {
if (jumped) {
falling += 0.5;
_y += falling;
if (touchingGround) {
jumped = false;
}
} else {
if (Key.isDown(Key.UP)) {
jumped = true;
falling = -jumpHeight;
this.gotoAndStop(4);
}
}
}
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.LEFT))) {
this.gotoAndStop(4);
}
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.RIGHT))) {
this.gotoAndStop(4);
}
if ((!Key.isDown(Key.UP)) and (!touchingGround)) {
this.gotoAndStop(4);
} else if ((Key.isDown(Key.UP)) and (!touchingGround)) {
this.gotoAndStop(4);
}
if ((_currentframe == 4) and (touchingGround)) {
gotoAndStop(1);
}
}
onClipEvent (keyUp) {
if (!attacked) {
gotoAndStop(1);
}
}
-
Prid - Outing
Too vague, could you post all the code for the character or even possibly the FLA file?
What you can try, though, is to right-click your jumping sound in your Library, pressing Linkage, ticking/checking Export for Actionscript, and typing in the Identifier field, jump_sound, pressing OK, and changing your code to this:
Actionscript Code:
onClipEvent (enterFrame) { if (!attacked) { if (jumped) { falling += 0.5; _y += falling; if (touchingGround) { jumped = false; } } else { if (Key.isDown(Key.UP)) { jumped = true; falling = -jumpHeight; this.gotoAndStop(4); jumpSound = new Sound(); jumpSound.attachSound("jump_sound"); jumpSound.start(); } } } if ((Key.isDown(Key.UP)) and (Key.isDown(Key.LEFT))) { this.gotoAndStop(4); } if ((Key.isDown(Key.UP)) and (Key.isDown(Key.RIGHT))) { this.gotoAndStop(4); } if ((!Key.isDown(Key.UP)) and (!touchingGround)) { this.gotoAndStop(4); } else if ((Key.isDown(Key.UP)) and (!touchingGround)) { this.gotoAndStop(4); } if ((_currentframe == 4) and (touchingGround)) { gotoAndStop(1); } } onClipEvent (keyUp) { if (!attacked) { gotoAndStop(1); } }
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
 Originally Posted by Nig 13
Too vague, could you post all the code for the character or even possibly the FLA file?
What you can try, though, is to right-click your jumping sound in your Library, pressing Linkage, ticking/checking Export for Actionscript, and typing in the Identifier field, jump_sound, pressing OK, and changing your code to this:
Actionscript Code:
onClipEvent (enterFrame) { if (!attacked) { if (jumped) { falling += 0.5; _y += falling; if (touchingGround) { jumped = false; } } else { if (Key.isDown(Key.UP)) { jumped = true; falling = -jumpHeight; this.gotoAndStop(4); jumpSound = new Sound(); jumpSound.attachSound("jump_sound"); jumpSound.start(); } } } if ((Key.isDown(Key.UP)) and (Key.isDown(Key.LEFT))) { this.gotoAndStop(4); } if ((Key.isDown(Key.UP)) and (Key.isDown(Key.RIGHT))) { this.gotoAndStop(4); } if ((!Key.isDown(Key.UP)) and (!touchingGround)) { this.gotoAndStop(4); } else if ((Key.isDown(Key.UP)) and (!touchingGround)) { this.gotoAndStop(4); } if ((_currentframe == 4) and (touchingGround)) { gotoAndStop(1); } } onClipEvent (keyUp) { if (!attacked) { gotoAndStop(1); } }
Here ya go, my full actionscript.
onClipEvent (load) {
var speed:Number = 0;
var walk:Number = 6;
var run:Number = 11;
var grav:Number = 0;
var falling:Number = 0;
var jumped:Boolean = false;
var jumpHeight:Number = 21;
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(Key.LEFT)) {
_x -= speed;
if(speed == walk){
this.gotoAndStop(2);
} else {
this.gotoAndStop(5); // running animation
}
_xscale = -scale;
}
if (Key.isDown(Key.RIGHT)) {
_x += speed;
if(speed == walk){
this.gotoAndStop(2);
} else {
this.gotoAndStop(5); // running animation
}
_xscale = +scale;
}
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(Key.UP)) {
jumped = true;
falling = -jumpHeight;
this.gotoAndStop(4);
}
}
}
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.LEFT))) {
this.gotoAndStop(4);
}
if ((Key.isDown(Key.UP)) and (Key.isDown(Key.RIGHT))) {
this.gotoAndStop(4);
}
if ((!Key.isDown(Key.UP)) and (!touchingGround)) {
this.gotoAndStop(4);
} else if ((Key.isDown(Key.UP)) and (!touchingGround)) {
this.gotoAndStop(4);
}
if ((_currentframe == 4) and (touchingGround)) {
gotoAndStop(1);
}
}
onClipEvent (keyUp) {
if (!attacked) {
gotoAndStop(1);
}
}
onClipEvent (enterFrame) {
if ((this.hitTest(_root.door)) and (!doorOpened)) {
this._x -= speed;
}
if ((this.hitTest(_root.door)) and (Key.isDown(Key.SPACE)) and (_root.keys>=1)) {
_root.door.gotoAndStop(2);
doorOpened = true;
_root.keys -= 1;
}
if (this.hitTest(_root.wall)) {
this._x -= speed;
}
if (this.hitTest(_root.key)) {
_root.keys += 1;
unloadMovie(_root.key);
}
if (_root.keys<0) {
_root.keys = 0;
}
}
onClipEvent (enterFrame) {
if (Key.isDown(65)){
attacked = true;
this.gotoAndStop(4);
if(this.hitTest(_root.enemy)) {
_root.enemy.unloadMovie();
}
} else {
attacked = false;
}
}
-
Prid - Outing
Why didn't you try the code in my previous post which I assumed would be the solution? Because it IS the solution, lol, if you want help then you shouldn't expect only the helper to aid you, you yourself should also try your best to contribute!
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
-
 Originally Posted by Nig 13
Why didn't you try the code in my previous post which I assumed would be the solution? Because it IS the solution, lol, if you want help then you shouldn't expect only the helper to aid you, you yourself should also try your best to contribute!
It sounds like the jumping sound is being played twice, making the sound echo, help?
-
Prid - Outing
that's because of your platform code which is causing the double jump. Change this:
Code:
if (!attacked) {
if (jumped) {
falling += 0.5;
_y += falling;
if (touchingGround) {
jumped = false;
}
} else {
if (Key.isDown(Key.UP)) {
jumped = true;
falling = -jumpHeight;
this.gotoAndStop(4);
}
}
}
to this:
Actionscript Code:
if (!attacked) { if (jumped) { falling += 0.5; _y += falling; if (touchingGround) { jumped = false; } } else { if (Key.isDown(Key.UP)) { jumped = true; _y -= jumpHeight; falling = -jumpHeight; this.gotoAndStop(4); } } }
and please, when you post codes, use the AS button when typing your codes, to make them appear as in my posts, 'cause it's a real pain to add all the indent later myself, thanks!
Last edited by Nig 13; 02-11-2012 at 11:15 AM.
I am back, guys ... and finally 18 :P
BRING BACK THE OLD DESIGN!! OR AT LEAST FIX THE AS TAGS
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|