close
Blogtrottr
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
Yahoo!奇摩知識+ - 分類問答 - 電腦網路 - 發問中
請問能否給點詳細說明下方程式碼的含義(上半)
Apr 19th 2013, 04:58

stop();

var r,r2:Number = 0;//半逕
var i:Number;
var direct:Number=1;
var timer_var:Number;

var power:Number=0.8;
var yspeed:Number=0;
var xspeed:Number=0;
var friction:Number=0.9;//控制越來越慢
var objKeyboard:Object;
var ddd:Array=new Array();
ddd=[0,0,0,0];

stage.addEventListener(Event.ENTER_FRAME,loop_fun);
stage.addEventListener(KeyboardEvent.KEY_DOWN, reportKeyDown);
stage.addEventListener(KeyboardEvent.KEY_UP, reportKeyUp);

function loop_fun(e:Event):void{
//----hero control---------------------------
xspeed*=friction;
yspeed*=friction;
hero.y+=yspeed;
hero.x+=xspeed;
//----hero control---------------------------
//----hero control---------------------------
var com_ddd:String=String(ddd[0]+""+ddd[1]+ddd[2]+ddd[3]);
//trace(com_ddd);
switch (Number(com_ddd)) {
case 0010 :
yspeed-=power*1.3;
break;
case 0001 :
yspeed+=power*1.3;
break;
case 1000 :
xspeed-=power*1.3;
break;
case 0100 :
xspeed+=power*1.3;
break;
}
//----hero control---------------------------

(r<300)? r+=5:r=0;
enemy.x +=4*direct;
if(enemy.x>450){direct=-1;}
if(enemy.x<90){ direct=1; }
timer_var=getTimer()/1000;
remove_bullet();
ger_bullet();
if(timer_var>=0.3){
(r2<300)? r2+=5:r2=0;
ger_bullet2();
}
//----histTest---------------------------
for (i=1;i<=20;i++){
var dect_eb:MovieClip = MovieClip(root).getChildByName("eb" + i);
if (HitTest.complexHitTestObject(dect_eb,hero,3)){ trace(111) }
}
//----histTest---------------------------
}//function

function ger_bullet(){
for (i=1; i<=20;i++) { // 一個下半圓帶入sin cos是由0-3.2 形成一個半弧
var eb:enemy_bullet=new enemy_bullet();
MovieClip(root).addChild(eb);
eb.name = "eb" + String( i );
eb.rotation=-(90-i*(180/20));//每一個子彈旋轉角
eb.x = r*Math.cos(i*3.2/20)+enemy.x;
eb.y = r*Math.sin(i*3.2/20)+enemy.y;

This entry passed through the Full-Text RSS service — if this is your content and you're reading it on someone else's site, please read the FAQ at fivefilters.org/content-only/faq.php#publishers. Five Filters recommends: Jousting With Toothpicks - The Case For Challenging Corporate Journalism http://www.medialens.org/index.php/alerts/alert-archive/alerts-2013/719-jousting-with-toothpicks-the-case-for-challenging-corporate-journalism.html.

You are receiving this email because you subscribed to this feed at blogtrottr.com.

If you no longer wish to receive these emails, you can unsubscribe from this feed, or manage all your subscriptions
arrow
arrow
    全站熱搜
    創作者介紹
    創作者 candycrushsaga2 的頭像
    candycrushsaga2

    line pokopang外掛程式教學 line pokopang外掛下載 line pokopang外掛程式下載 line pokopang外掛程式

    candycrushsaga2 發表在 痞客邦 留言(0) 人氣()