Ignore:
Timestamp:
01/22/12 03:41:27 (12 years ago)
Author:
atzm
Message:

bgm/se support

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pycodeshooter/trunk/shooter/trooper.js

    r114 r119  
    7575 
    7676    this.bullets    = new Array(); 
     77    this.callbacks  = {}; 
    7778    this.bomb       = null; 
    7879    this.name       = name; 
     
    172173 
    173174            // update my life 
    174             if (hit && this.life > 0) 
     175            if (hit && this.life > 0) { 
    175176                this.life--; 
     177 
     178                if (this.callbacks["damaged"]) 
     179                    this.callbacks["damaged"](this); 
     180            } 
    176181        } 
    177182    }; 
     
    215220        this.bullets.push( 
    216221            new bulletType(size, color, frame, this.w, this.h, this.x + x, this.y + y, dir, speed)); 
     222 
     223        if (this.callbacks["addBullet"]) 
     224            this.callbacks["addBullet"](this); 
    217225    }; 
    218226 
     
    242250                                 this.size * 2, 10, this.bombColors); 
    243251            this.numBombs--; 
    244         } 
     252 
     253            if (this.callbacks["addBomb"]) 
     254                this.callbacks["addBomb"](this); 
     255        } 
     256    }; 
     257 
     258    this.registerCallback = function(name, callback) { 
     259        this.callbacks[name] = callback; 
    245260    }; 
    246261} 
Note: See TracChangeset for help on using the changeset viewer.