1 Replies - 1324 Views - Last Post: 31 December 2008 - 06:29 AM

#1 reyco1  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 2
  • View blog
  • Posts: 43
  • Joined: 20-March 05

Cannon that shoots! very simple

Posted 27 March 2005 - 07:09 AM

Description: Make three movieclips a name them "bullet", "cannon" and "base". Make the fps 35.The rest of the instructions are on the AS code.Make a cannon shoot bullets on mouse click.
//place this code on the bullet
onClipEvent (load) {
     this._visible = 0;
     if (_root.fire == 1) {
          this._x = _root.cannon._x;
          this._y = _root.cannon._y;
     }
}
onClipEvent (enterFrame) {
     if (this != _level0.bullet) {
          if (_root.fire == 1) {
               this._y -= 5;
               this._visible = 1;
          }
          if (this._y<0) {
               this.removeMovieClip();
          }
     }
}
//place this code on the cannon
on (release) {
     _root.fire = 1;
     _root.i += 1;
     duplicateMovieClip(_root.bullet, "bullet"+i, i);
}
//place this code on "Base"
//this clip is used to turn 
//the cursur into the cannon
onClipEvent (load) {
     this._visible = 0;
     Mouse.hide();
}
onClipEvent (enterFrame) {
     _root.cannon._x = _root._xmouse;
     _root.cannon._y = _root._ymouse;
}



Is This A Good Question/Topic? 0
  • +

Replies To: Cannon that shoots! very simple

#2 GreenSpiral  Icon User is offline

  • D.I.C Head

Reputation: 2
  • View blog
  • Posts: 64
  • Joined: 30-December 08

Re: Cannon that shoots! very simple

Posted 31 December 2008 - 06:29 AM

Haven't tried it but the part with the cannon moving is useful to me :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1