danb
04-05-2005, 04:21 PM
Hi,
I have a keyboard-bashing game, which uses this code to do the work:
onClipEvent (keyDown) {
bounce = false;
xscale = Number(xscale*1.008);
yscale = Number(yscale*0.992);
}
onClipEvent (keyUp) {
bounce = false;
xscale = Number(100);
yscale = Number(100);
}
onClipEvent (keyDown) {
intCount++;
_level1.intTotalCount++;
if (intCount==1) {
loadMovieNum("sound2.swf",2);
loaded=math.round(_level1.getBytesLoaded());
if (loaded<1) {
loadMovieNum("countdown.swf",1);
}
}
if ((intCount==1)||(intCount==4)||(intCount==10)||(in tCount==26)||(intCount==38)||(intCount==44)||(intC ount==52)) {
singer.Play();
}
setProperty(singer.mouth,_xscale,((intCount/0.8)+65));
setProperty(singer.mouth,_yscale,((intCount/0.8)+65));
if (intCount==22){
loadMovieNum("sound2.swf",3);
}
if (intCount==28){
loadMovieNum("sound2.swf",4);
}
if (intCount==38){
loadMovieNum("sound2.swf",5);
}
if (intCount==32) {
singer.eyes.Play();
loadMovieNum("sound3.swf",6);
}
if (intCount>=24) {
setProperty(singer.eyes,_xscale,((intCount/0.8)+65));
setProperty(singer.mouth,_yscale,((intCount/0.8)+65));
}
if (intCount>=20) {
setProperty (singer, _xscale, (((intCount-20)/12)+30));
}
if (intCount==52) {
unloadMovieNum(2);
unloadMovieNum(3);
unloadMovieNum(4);
unloadMovieNum(5);
unloadMovieNum(6);
_global.intHelmets++;
_root.play();
}
}
It can probably be shortened and optimised, but I'm not worried about that now.
I basically need to stop someone from holding the key down which is obviously cheating!
I've found this code posted elsewhere on the forum, but my lack of actionscript knowlege means that I have no idea how to apply it:
controls = new Object()
controls.onKeyDown = function() {
if (Key.isDown(Key.SPACE) == true && spaceDown == false) {
moving = true
player.gotoAndPlay(5)
spaceDown = true
}
}
controls.onKeyUp = function() {
if (Key.isDown(Key.SPACE) == false && spaceDown == true) {
spaceDown = false
}
}
Key.addListener(controls)
Can anyone show me how to combine the two? I'm really crap when it comes to actionscript, so the simpler the better!
Thanks very much...
I have a keyboard-bashing game, which uses this code to do the work:
onClipEvent (keyDown) {
bounce = false;
xscale = Number(xscale*1.008);
yscale = Number(yscale*0.992);
}
onClipEvent (keyUp) {
bounce = false;
xscale = Number(100);
yscale = Number(100);
}
onClipEvent (keyDown) {
intCount++;
_level1.intTotalCount++;
if (intCount==1) {
loadMovieNum("sound2.swf",2);
loaded=math.round(_level1.getBytesLoaded());
if (loaded<1) {
loadMovieNum("countdown.swf",1);
}
}
if ((intCount==1)||(intCount==4)||(intCount==10)||(in tCount==26)||(intCount==38)||(intCount==44)||(intC ount==52)) {
singer.Play();
}
setProperty(singer.mouth,_xscale,((intCount/0.8)+65));
setProperty(singer.mouth,_yscale,((intCount/0.8)+65));
if (intCount==22){
loadMovieNum("sound2.swf",3);
}
if (intCount==28){
loadMovieNum("sound2.swf",4);
}
if (intCount==38){
loadMovieNum("sound2.swf",5);
}
if (intCount==32) {
singer.eyes.Play();
loadMovieNum("sound3.swf",6);
}
if (intCount>=24) {
setProperty(singer.eyes,_xscale,((intCount/0.8)+65));
setProperty(singer.mouth,_yscale,((intCount/0.8)+65));
}
if (intCount>=20) {
setProperty (singer, _xscale, (((intCount-20)/12)+30));
}
if (intCount==52) {
unloadMovieNum(2);
unloadMovieNum(3);
unloadMovieNum(4);
unloadMovieNum(5);
unloadMovieNum(6);
_global.intHelmets++;
_root.play();
}
}
It can probably be shortened and optimised, but I'm not worried about that now.
I basically need to stop someone from holding the key down which is obviously cheating!
I've found this code posted elsewhere on the forum, but my lack of actionscript knowlege means that I have no idea how to apply it:
controls = new Object()
controls.onKeyDown = function() {
if (Key.isDown(Key.SPACE) == true && spaceDown == false) {
moving = true
player.gotoAndPlay(5)
spaceDown = true
}
}
controls.onKeyUp = function() {
if (Key.isDown(Key.SPACE) == false && spaceDown == true) {
spaceDown = false
}
}
Key.addListener(controls)
Can anyone show me how to combine the two? I'm really crap when it comes to actionscript, so the simpler the better!
Thanks very much...