Code analysis of a direction control shot game! (AS1.0)

xiaoxiao2021-03-06  64

I saw a small game today, I analyzed it ... (Original address: http://www.gotoandplay.it/_articles/2003/10/shoot.php) I have made the main function, you Can download program research research! Preparation: Place some movie clips on the stage! As shown in illustration, temporary tolerance, technology is first! The code above the Ball is: OnClipevent (LOAD) {Dirright = 1; // Fire direction of the bullet in the future Speed ​​= 5; // Run speed D = 0; // The depth of the movie of the first bullet. . . } OnClipevent (Enterframe) {if (Key.IgH.right)) {Dirright = 1; this._xscale = 70; this._x = speed;} else if (key.LEFT)) {Dirright = 0; this._xscale = -70; this._x - = speed;} // Basic motion control, do not understand, you can see my last ... IF (Key.Isdown Key.Space)) {//trace (key.isdown) // Pressing the space bar // a for the button will not make continuous bullets. . . Set of one flag bit if (! A) {d ; bulletDepth = (D% 100); // 100 year a turn back duplicateMovieClip (_parent.bullet, "new" bulletDepth, bulletDepth; // Copy bullets .. (Dirright == 1) {_parent ["New" bulletDepth] .speed = 20; _parent ["New" BulletDepth] .stepx = 40;} // Set the direction of the bullet and Stepx is in front of the Ball Distance, this can be seen in the Bullet's code _root.ball._x stepx; if (Dirright == 0) {_parent ["New" bulletDepth] .speed = -20; _parent [ "New" bulletDepth] .stepx = -40;} // 同 同 = true; // Sign bit, press it to stop}} else = false; // The same flag is! }}} Bullet (Bullet code) OnClipEvent (LOAD) {mannum = 4; // A total of several people if (_name! = bullet) {this._x = _root.ball._x stepx * 2; this._y = _root. Ball._y; // Set the data set in Ball! MySound = new Sound (); mysound.attachsound ("zap"); // load sound}} onclipevent (enterframe) {if (_name! = Bullet) {this._x =

转载请注明原文地址:https://www.9cbs.com/read-86109.html

New Post(0)