スクリプト改善
おねがいします
こちらのスクリプトは縦スクロールの音ゲームです。こちらを編集して横スクロールの音ゲームにしてもらえませんか?自分でやってもなかなかできなくて、、、
mport flash.events.Event;
import flash.display.DisplayObject;
import flash.events.KeyboardEvent;
stop();
var se:SE1 = new SE1();
var hit:int,time:int;
const speed:int = 10;
var key:Array = [65,83,68,70,74,75,76,187];
var timeline:int = 0;
var onp_y:Array = new Array();
init();
function init(){
txt_score.text = "0";
txt_combo.text = "0";
hit = 0;
onp_y[0] = [36,110];
onp_y[1] = [42,123];
onp_y[2] = [48,155];
onp_y[3] = [81,165];
onp_y[4] = [89,200];
onp_y[5] = [95,211];
onp_y[6] = [103,260];
onp_y[7] = [110,300];
var onp_x = [160,220,280,340,460];
var clazz:Class = getDefinitionByName("o_001") as Class;
for (var k:int=0; k<onp_y.length; k++){
for(var i:int=0; i<onp_y[k].length; i++){
var obj = new clazz();
obj.name = "onp"+k+i;
obj.addEventListener
(Event.ENTER_FRAME,update_onp);
addChild(obj);
obj.x = onp_x[k];
obj.y = -onp_y[k][i]*speed+mc_line.y;
trace(-onp_y[k][i]);
if(time < onp_y[k][i]){
time = onp_y[k][i];
}
}
}
time += 12; //0.5秒
stage.addEventListener(KeyboardEvent.KEY_DOWN,pressKey);
stage.addEventListener(Event.ENTER_FRAME,update_stage);
stage.focus = stage;
}
function term(){
for(var k:int=0; k<onp_y.length; k++){
for(var i:int=0; i<onp_y[k].length; i++){
var ins:DisplayObject = getChildByName("onp"+k+i);
ins.removeEventListener(Event.ENTER_FRAME,update_onp);
removeChild(ins);
}
}
stage.removeEventListener(KeyboardEvent.KEY_DOWN,pressKey);
stage.removeEventListener(Event.ENTER_FRAME,update_stage);
SoundMixer.stopAll();
}
function update_stage(e:Event){
timeline++;
if(timeline>time){
term();
if(hit<4){
gotoAndStop("bad");
}else if(hit<8){
gotoAndStop("nice");
}else{
gotoAndStop("great");
}
}
}
function update_onp(e:Event){
var ins:Object = e.target;
ins.y += speed;
if(400<ins.y && ins.visible == true){
txt_combo.text = "0";
ins.visible = false;
mc_hantei.gotoAndPlay("miss");
}
}
function pressKey(e:KeyboardEvent){
for(var k:int = 0;k<key.length;k++){
for(var i:int = 0; i<onp_y[k].length; i++){
var ins:Object = getChildByName("onp"+k+i);
if(e.keyCode ==
key[k] && ins.hitTestObject(mc_line) && ins.visible == true){
txt_score.text = String(Number(txt_score.text)+10);
txt_combo.text = String(Number(txt_combo.text)+1);
hit += 1;
//se.play();
ins.visible = false;
mc_hantei.gotoAndPlay("great");
k++;
break;
}
}
}
}
お礼
わかりやすい回答ありがとうございます!この方法で動かすことができました。本当に助かりました。