egmcmac
12-17-2008, 09:33 PM
Hey, I'm new here, but I was wondering if anyone could help me out. I've been trying to make a guitarhero like game for quite awhile. I finally found this tutorial on how to make a DDR, so I basically took that, changed a few models around and attempted to make it guitar hero based. My AS is pretty simple.
What I need to know is how to make it so that rather than pressing A, S, D, F for the button AND strumming, to make it so that you also need to press backspace. I have tried a variety of things, but hopefully you people will know how to fix it. My current AS is below. Everything else is working perfectly.
Also heres something to help you out;
Green button is called arrowLeft
Red button is called arrowUp
Yellow button is called arrowDown
Blue button is called arrowRight
ACTIONSCRIPT!!!
stop();
var sTime:Number = 0;
var sTempo:Number = 12;
var sArrow:Number = 0;
var arrowSpeed:Number = 4;
var gameIsOver:Boolean = false;
var score:Number = 0;
var scoreString:String = '';
var touchLeft:Boolean = false;
var touchUp:Boolean = false;
var touchDown:Boolean = false;
var touchRight:Boolean = false;
var combo:Number = 0;
function beginCode():Void {
onEnterFrame = function () {
makeLvl();
};
lvlArrayAll[lvlCurrent].push(0,0,0,0,0);
}
function makeLvl():Void {
if (sTime<sTempo) {
sTime++;
} else {
sTime = 0;
if (lvlArrayAll[lvlCurrent][sArrow] != 0) {
if (lvlArrayAll[lvlCurrent][sArrow] == 1) {
attachMovie('arrowLeft','arrow'+sArrow,getNextHigh estDepth());
_root['arrow'+sArrow]._x = 135;
_root['arrow'+sArrow].arrowCode = 65;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 2) {
attachMovie('arrowUp','arrow'+sArrow,getNextHighes tDepth());
_root['arrow'+sArrow]._x = 205;
_root['arrow'+sArrow].arrowCode = 83;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 3) {
attachMovie('arrowDown','arrow'+sArrow,getNextHigh estDepth());
_root['arrow'+sArrow]._x = 275;
_root['arrow'+sArrow].arrowCode = 68;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 4) {
attachMovie('arrowRight','arrow'+sArrow,getNextHig hestDepth());
_root['arrow'+sArrow]._x = 345;
_root['arrow'+sArrow].arrowCode = 70;
}
_root['arrow'+sArrow]._y = 195;
_root['arrow'+sArrow].gotHit = false;
_root['arrow'+sArrow].onEnterFrame = function() {
this._y += arrowSpeed;
if (this.hitTest(_root.mcReceptor) && !this.gotHit) {
if (Key.isDown(this.arrowCode)) {
if (this._y<=mcReceptor._y+15 && this._y>=mcReceptor._y+5) {
score += 10;
scoreString = 'Perfect';
changeHealth(5);
} else if (this._y<=mcReceptor._y+25 && this._y>=mcReceptor._y-5) {
score += 8;
scoreString = 'Great';
changeHealth(4);
} else if (this._y<=mcReceptor._y+40 && this._y>=mcReceptor._y-30) {
score += 6;
scoreString = 'Nice';
changeHealth(3);
} else {
score += 4;
scoreString = 'Good';
changeHealth(2);
}
combo++;
this._visible = false;
this.gotHit = true;
}
}
if (this._y>=400) {
if (!this.gotHit) {
changeHealth(-10);
scoreString = 'Bad';
combo = 0;
}
this.removeMovieClip();
}
};
}
if (sArrow<lvlArrayAll[lvlCurrent].length && !gameIsOver) {
sArrow++;
} else {
gotoAndStop('win');
gameIsOver = true;
for (var i:Number = 0; i<sArrow; i++) {
_root['arrow'+i].removeMovieClip();
}
onEnterFrame = null;
}
}
}
function changeHealth(healthDiff:Number):Void {
if (mcHealth._xscale+healthDiff>=100) {
mcHealth._xscale = 100;
} else if (mcHealth._xscale+healthDiff<=0) {
gameIsOver = true;
for (var i:Number = 0; i<sArrow; i++) {
_root['arrow'+i].removeMovieClip();
}
gotoAndStop('lose');
onEnterFrame = null;
} else {
mcHealth._xscale += healthDiff;
}
}
mcReceptor.onEnterFrame = function() {
touchLeft = false;
touchUp = false;
touchDown = false;
touchRight = false;
for (i=sArrow-10; i<=sArrow; i++) {
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == 65) {
touchLeft = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchUp = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchDown = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchRight = true;
}
}
if (Key.isDown(Key.BACKSPACE) && !touchLeft) {
changeHealth(-10);
scoreString = 'Bad';
combo = 0;
}
};
beginCode();
Thanks again,
EgMcMac :o
What I need to know is how to make it so that rather than pressing A, S, D, F for the button AND strumming, to make it so that you also need to press backspace. I have tried a variety of things, but hopefully you people will know how to fix it. My current AS is below. Everything else is working perfectly.
Also heres something to help you out;
Green button is called arrowLeft
Red button is called arrowUp
Yellow button is called arrowDown
Blue button is called arrowRight
ACTIONSCRIPT!!!
stop();
var sTime:Number = 0;
var sTempo:Number = 12;
var sArrow:Number = 0;
var arrowSpeed:Number = 4;
var gameIsOver:Boolean = false;
var score:Number = 0;
var scoreString:String = '';
var touchLeft:Boolean = false;
var touchUp:Boolean = false;
var touchDown:Boolean = false;
var touchRight:Boolean = false;
var combo:Number = 0;
function beginCode():Void {
onEnterFrame = function () {
makeLvl();
};
lvlArrayAll[lvlCurrent].push(0,0,0,0,0);
}
function makeLvl():Void {
if (sTime<sTempo) {
sTime++;
} else {
sTime = 0;
if (lvlArrayAll[lvlCurrent][sArrow] != 0) {
if (lvlArrayAll[lvlCurrent][sArrow] == 1) {
attachMovie('arrowLeft','arrow'+sArrow,getNextHigh estDepth());
_root['arrow'+sArrow]._x = 135;
_root['arrow'+sArrow].arrowCode = 65;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 2) {
attachMovie('arrowUp','arrow'+sArrow,getNextHighes tDepth());
_root['arrow'+sArrow]._x = 205;
_root['arrow'+sArrow].arrowCode = 83;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 3) {
attachMovie('arrowDown','arrow'+sArrow,getNextHigh estDepth());
_root['arrow'+sArrow]._x = 275;
_root['arrow'+sArrow].arrowCode = 68;
} else if (lvlArrayAll[lvlCurrent][sArrow] == 4) {
attachMovie('arrowRight','arrow'+sArrow,getNextHig hestDepth());
_root['arrow'+sArrow]._x = 345;
_root['arrow'+sArrow].arrowCode = 70;
}
_root['arrow'+sArrow]._y = 195;
_root['arrow'+sArrow].gotHit = false;
_root['arrow'+sArrow].onEnterFrame = function() {
this._y += arrowSpeed;
if (this.hitTest(_root.mcReceptor) && !this.gotHit) {
if (Key.isDown(this.arrowCode)) {
if (this._y<=mcReceptor._y+15 && this._y>=mcReceptor._y+5) {
score += 10;
scoreString = 'Perfect';
changeHealth(5);
} else if (this._y<=mcReceptor._y+25 && this._y>=mcReceptor._y-5) {
score += 8;
scoreString = 'Great';
changeHealth(4);
} else if (this._y<=mcReceptor._y+40 && this._y>=mcReceptor._y-30) {
score += 6;
scoreString = 'Nice';
changeHealth(3);
} else {
score += 4;
scoreString = 'Good';
changeHealth(2);
}
combo++;
this._visible = false;
this.gotHit = true;
}
}
if (this._y>=400) {
if (!this.gotHit) {
changeHealth(-10);
scoreString = 'Bad';
combo = 0;
}
this.removeMovieClip();
}
};
}
if (sArrow<lvlArrayAll[lvlCurrent].length && !gameIsOver) {
sArrow++;
} else {
gotoAndStop('win');
gameIsOver = true;
for (var i:Number = 0; i<sArrow; i++) {
_root['arrow'+i].removeMovieClip();
}
onEnterFrame = null;
}
}
}
function changeHealth(healthDiff:Number):Void {
if (mcHealth._xscale+healthDiff>=100) {
mcHealth._xscale = 100;
} else if (mcHealth._xscale+healthDiff<=0) {
gameIsOver = true;
for (var i:Number = 0; i<sArrow; i++) {
_root['arrow'+i].removeMovieClip();
}
gotoAndStop('lose');
onEnterFrame = null;
} else {
mcHealth._xscale += healthDiff;
}
}
mcReceptor.onEnterFrame = function() {
touchLeft = false;
touchUp = false;
touchDown = false;
touchRight = false;
for (i=sArrow-10; i<=sArrow; i++) {
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == 65) {
touchLeft = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchUp = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchDown = true;
}
if (this.hitTest(_root['arrow'+i]) && _root['arrow'+i].arrowCode == Key.BACKSPACE) {
touchRight = true;
}
}
if (Key.isDown(Key.BACKSPACE) && !touchLeft) {
changeHealth(-10);
scoreString = 'Bad';
combo = 0;
}
};
beginCode();
Thanks again,
EgMcMac :o