私はjavascript上で非常に新しいです、私はいくつかの小惑星を殺さなければならない船の賭博をしていました、そしてあなたがスクリーン上の "オブジェクト"のいくつかの異なるものを取るとき、私たちは弾丸の数を広げます。オキー、ポイントに行くと、私はdiffirentsオブジェクトを取るときに画面上に3つの弾丸を得ることができましたが、今は、配列の3つの弾丸のうち2つに異なる方向を与えたいと思います。私が試したとき、私は3つの弾丸に同じ方向を与えるという問題があります、なぜ私は知っていますが、少なくとも5時間この問題を解決しようとすると私は傾ける。1つの配列に異なる弾丸の方向を与える方法は?
異なるクラスのFlash Builder 4.7でのプログラミングでは、メインにある配列のコードと、弾丸クラスもヒーロークラスに渡します。ここ
メインアレイ
public function evUpdateBullet():void//here execute update of my class Bullets
{
var i:int;
for(i=myBullets.length-1; i >= 0; i--)
{
if(myBullets != null) //to be ?
{
if(myBullets[i].isDestroyed) //is destroyed Bullets?
{
myBullets[i] = null;
myBullets.splice(i, 1); //deleted elements.
}else
{
myBullets[i].evUpdate();
}
}
}
}
私は配列をプッシュし、箇条書きを作成し、myBulletsを覚えている配列の名前です。ここで
public function evShoot(posX:int, posY:int):void//here create the bullet and push in the array
{
attack1 = new Bullet;
attack1.Spawn(posX, posY);
myBullets.push(attack1);
}
私は弾丸の位置が画面上に出現しようとしている定義ヒーローコードを示します。ここで
if (isPressing_Shoot && !isDestroyed)// Here execute the event shoot without power
{
Main.instace.evShoot(model.x, model.y);
isPressing_Shoot = false;
canShoot = false;
}
evDestroyed();
}
は
第ブレットクラス次にスポーン
public function Spawn(posX:int, posY:int):void
{
isDestroyed = false;//first parameter of my bullet
model = new MCbullet;
Main.layer1.addChild(model);//painting the hero in the stage
model.x = posX;//position in the stage wiht the hero
model.y = posY;
model.tigger.visible = false;
}
iはYの動きを設定し、このアップデートで更新
public function evUpdate():void//here conect with update general
{
if (model != null)//to be?
{
model.y -= 12;//move of my bullet
//model.x -= 12;
if (model.y <= 0)
{
evDestroyed();
}
}
}
からのコードであるので、私私はx.moveを追加しようとすると、私はすべての配列のために行うので、私はどのように私が与えることができます知ってほしい同じ配列の異なった箇条書きのために移動する。
JavaScriptの新機能には何がありますか? –