⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 tool2.as

📁 小鱼历险记游戏
💻 AS
字号:
import game.phys.Particle;
import mx.utils.Delegate;
//补充_score点
class game.tool.Tool2 extends game.tool.Tool {
	private var _score = 5
	function Tool2() {
		_id = "tool2";
		_total = 5
	}
	//创建一只鱼
	public function create():Void {
		var depth = _path.getNextHighestDepth();
		var t:MovieClip = _path.attachMovie(_id, "fish"+depth, depth);
		t._x = random(800)-200;
		t._y = 330;
		t.gotoAndStop(random(4)+1);
		move(t);
	}
	private function move(obj) {
		var t:Particle = new Particle();
		t._target = obj;
		t.addEventListener("onStop", Delegate.create(this, init));
		t.addEventListener("onPlay", Delegate.create(this, setEvent));
		init();
		//重新移动
		function init() {
			t._time = random(50)+100;
			t._endx = random(950)-400
			t._endy = random(50);
			t.play();
		}
		function setEvent() {
			if (_hero.hitTest(obj)) {
				//吃食物的声音
				var my_sound:Sound = new Sound();
				my_sound.attachSound("eat");
				my_sound.start();
				//加上相应的生命
				_heroIns.setScore(_score);
				createScore("score_0", obj, "+", _score);
				obj.removeMovieClip();
				create();
			}
			if (obj._y<60) {
				obj.removeMovieClip();
				create();
			}
		}
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -