Andy|Robot
02-27-2009, 01:11 AM
My problem is there is so much information on character movement that i can't find the piece of information i need.
Basically my background moves and the character jumps separating, but it has a pause when holding LEFT then jumping the LEFT movement in the background will stop and only start after the jump key has been released and pressed again or untill the left has been released and pressed again. I'ts most likely to do with all the stop(); 's i have.
The animation has 2 elements - a rotating background and a jumping/flipping character, this is all test work to implement into a game later on.
.FLA file: rotatecontrolcharacters1.fla (http://andy.gamescreator.googlepages.com/rotatecontrolcharactertest1.fla)
Character_mc code:
onClipEvent (load) {
jumping = false;
velocity = 10;
stop();
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
jumping = true;
}
if (jumping) {
this._y -= velocity/2;
velocity -= .3;
}
if (this._y > 104) {
jumping = false;
velocity = 10;
}
}
onClipEvent (keyDown) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("Right");
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("Left");
}
}
onClipEvent (keyUp) {
if (!Key.isDown(Key.LEFT || Key.RIGHT)) {
this.gotoAndStop("Front");
}
}
Background_mc code:
onClipEvent (enterFrame) {
this.stop();
}
onClipEvent (keyDown) {
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe > 299){
this.gotoAndStop(1);
this._currentframe = 1
}else{
this.gotoAndStop(this._currentframe +1 );
}
}
if (Key.isDown(Key.LEFT)) {
if (this._currentframe < 2){
this.gotoAndStop(300);
this._currentframe = 300
}else{
this.gotoAndStop(this._currentframe -1);
}
}
}
onClipEvent (keyUp) {
if (!Key.isDown(Key.LEFT || Key.RIGHT)) {
this.stop();
}
}
Help is much appreciated :)
Andy
Basically my background moves and the character jumps separating, but it has a pause when holding LEFT then jumping the LEFT movement in the background will stop and only start after the jump key has been released and pressed again or untill the left has been released and pressed again. I'ts most likely to do with all the stop(); 's i have.
The animation has 2 elements - a rotating background and a jumping/flipping character, this is all test work to implement into a game later on.
.FLA file: rotatecontrolcharacters1.fla (http://andy.gamescreator.googlepages.com/rotatecontrolcharactertest1.fla)
Character_mc code:
onClipEvent (load) {
jumping = false;
velocity = 10;
stop();
}
onClipEvent (enterFrame) {
if (Key.isDown(Key.UP)) {
jumping = true;
}
if (jumping) {
this._y -= velocity/2;
velocity -= .3;
}
if (this._y > 104) {
jumping = false;
velocity = 10;
}
}
onClipEvent (keyDown) {
if (Key.isDown(Key.RIGHT)) {
this.gotoAndStop("Right");
}
if (Key.isDown(Key.LEFT)) {
this.gotoAndStop("Left");
}
}
onClipEvent (keyUp) {
if (!Key.isDown(Key.LEFT || Key.RIGHT)) {
this.gotoAndStop("Front");
}
}
Background_mc code:
onClipEvent (enterFrame) {
this.stop();
}
onClipEvent (keyDown) {
if (Key.isDown(Key.RIGHT)) {
if (this._currentframe > 299){
this.gotoAndStop(1);
this._currentframe = 1
}else{
this.gotoAndStop(this._currentframe +1 );
}
}
if (Key.isDown(Key.LEFT)) {
if (this._currentframe < 2){
this.gotoAndStop(300);
this._currentframe = 300
}else{
this.gotoAndStop(this._currentframe -1);
}
}
}
onClipEvent (keyUp) {
if (!Key.isDown(Key.LEFT || Key.RIGHT)) {
this.stop();
}
}
Help is much appreciated :)
Andy