Commit de95c2f0 by tianpan1

删除多余文件

parent 2e30037d
......@@ -12,16 +12,13 @@
"libs/modules/particle/particle.js"
],
"game": [
"bin-debug/game/GameContainer.js",
"bin-debug/game/Background.js",
"bin-debug/AssetAdapter.js",
"bin-debug/LoadingUI.js",
"bin-debug/Main.js",
"bin-debug/Music.js",
"bin-debug/People.js",
"bin-debug/ThemeAdapter.js",
"bin-debug/Background.js",
"bin-debug/game/BgMap.js",
"bin-debug/game/GameContainer.js",
"bin-debug/AssetAdapter.js",
"bin-debug/game/GameUtil.js",
"bin-debug/game/Gold.js",
"bin-debug/game/People.js",
......
No preview for this file type
class Background extends eui.Component{
public btn: eui.Button;
private score: eui.Label;
private title: eui.Label;
private people: People;
public constructor() {
super();
//加载背景
this.skinName = "resource/skin/StartPanel.exml";
this.addEventListener(egret.Event.COMPLETE, this.onAddToStage, this);
//创建一个计时器对象
// var timer:egret.Timer = new egret.Timer(30,0);
// //注册事件侦听器
// timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this);
// timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.timerComFunc,this);
// //开始计时
// timer.start();
// this.keyDown();
}
private onAddToStage(event:egret.Event){
this.people = new People();
this.addChild(this.people);
this.btn.addEventListener(egret.TouchEvent.TOUCH_TAP,this.clickBtn,this);
//设置显示对象可以相应触摸事件
this.people.touchEnabled = true;
//注册事件
this.people.addEventListener(egret.TouchEvent.TOUCH_BEGIN, this.mouseDown, this);
this.people.addEventListener(egret.TouchEvent.TOUCH_END, this.mouseUp, this);
}
private clickBtn(ev:egret.TouchEvent){
this.removeChild(this.btn);
this.removeChild(this.title)
this.score.visible = false;
// this.addChild(this.people);
this.people.y=this.stage.stageHeight-this.people.height/2-10;
this.people.x = (this.stage.stageWidth-this.people.width)/2+80;
this.people.scaleX = 0.5;
this.people.scaleY = 0.5;
}
private _touchStatus:boolean = false; //当前触摸状态,按下时,值为true
private _distance:egret.Point = new egret.Point(); //鼠标点击时,鼠标全局坐标与people的位置差
private mouseDown(evt:egret.TouchEvent)
{
console.log("Mouse Down.");
this._touchStatus = true;
this._distance.x = evt.stageX - this.people.x;
this.stage.addEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMove, this);
}
private mouseMove(evt:egret.TouchEvent)
{
if( this._touchStatus )
{
console.log("moving now ! Mouse: [X:"+evt.stageX+",Y:"+evt.stageY+"]");
this.people.x = evt.stageX - this._distance.x;
console.log(this.people.x);
if(this.people.x<-20){
this.people.x=-20
}else if(this.people.x>520){
this.people.x=520;
}
}
}
private mouseUp(evt:egret.TouchEvent)
{
console.log("Mouse Up.");
this._touchStatus = false;
this.stage.removeEventListener(egret.TouchEvent.TOUCH_MOVE, this.mouseMove, this);
}
// private keyDown(){
// var that = this;
// document.addEventListener("keydown",function onkeydown(event:KeyboardEvent){
// var keycode = event.keyCode;
// if(keycode == 37) {
// console.log('向左走');
// }else if(keycode == 39){
// console.log('向右走');
// }
// });
// }
// private timerFunc()
// {
// console.log("计时");
// this.people.x += 1;
// console.log(this.people);
// if(this.people.x>=640 || this.people.x<=0){this.people.x=0;}
// }
// private timerComFunc()
// {
// console.log("计时结束");
// }
// private timeOnEnterFrame:number = 0;
// private onLoad(event:egret.Event) {
// this.addEventListener(egret.Event.ENTER_FRAME,this.onEnterFrame,this);
// this.timeOnEnterFrame = egret.getTimer();
// }
// private onEnterFrame(e:egret.Event){
// var p = new People();
// p.x ==10;
// console.log(p.x);
// // var now = egret.getTimer();
// // var time = this.timeOnEnterFrame;
// // var pass = now - time;
// // console.log("onEnterFrame: ", (1000 / pass).toFixed(5));
// // this.timeOnEnterFrame = egret.getTimer();
// }
}
\ No newline at end of file
/**
* 可以通过点击播放、暂停、结束来对声音进行控制,并可以在进度条中查看对应播
* 放进度。
*/
class Music extends egret.DisplayObjectContainer {
//背景音效
private _sound: egret.Sound;
//吸金币音效
private _gold: egret.Sound;
//吸地雷音效
private _bomb:egret.Sound;
private _channel: egret.SoundChannel;
constructor() {
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}
private onAddToStage(event: egret.Event) {
this.loadSound();
}
//加载
private loadSound() {
//背景音效
// this._sound = new egret.Sound();;
// //sound 加载完成监听
// this._sound.addEventListener(egret.Event.COMPLETE, function (e: egret.Event) {
// this._sound.play();
// this.init();
// }, this);
// this._sound.load("resource/assets/a.mp3");
var music = RES.getRes("a_mp3");
console.log(music);
this._sound = RES.getRes("a_mp3");
}
//播放
public play():void {
//sound 播放会返回一个 SoundChannel 对象,暂停、音量等操作请控制此对象
this._channel = this._sound.play();
}
停止
private stop():void {
if (this._channel) {
this._channel.stop();
this._channel = null;
}
}
}
\ No newline at end of file
class People extends egret.DisplayObjectContainer
{
private _mcData:any;
private _mcTexture:egret.Texture;
constructor() {
super();
this.addEventListener(egret.Event.ADDED_TO_STAGE, this.onAddToStage, this);
}
private onAddToStage(event: egret.Event) {
this.load(this.initMovieClip);
}
private initMovieClip():void {
/*** 本示例关键代码段开始 ***/
var mcDataFactory = new egret.MovieClipDataFactory(this._mcData, this._mcTexture);
var role:egret.MovieClip = new egret.MovieClip(mcDataFactory.generateMovieClipData("attack"));
this.addChild(role);
role.gotoAndPlay(1, 3);
role.x = (this.stage.stageWidth-role.width)/2+100;
role.y = this.stage.stageHeight;
role.scaleX=0.5;
role.scaleY=0.5;
console.log(role);
// role.width= 500;
// role.height = 600;
role.addEventListener(egret.Event.COMPLETE, function (e:egret.Event):void {
egret.log("play over!")
}, this);
var count:number = 0;
role.addEventListener(egret.Event.LOOP_COMPLETE, function (e:egret.Event):void {
egret.log("play times:" + ++count);
}, this);
role.addEventListener(egret.MovieClipEvent.FRAME_LABEL, function (e:egret.MovieClipEvent):void {
egret.log("frameLabel:" + e.frameLabel);
}, this);
this.stage.addEventListener(egret.TouchEvent.TOUCH_TAP, function (e:egret.TouchEvent):void {
count = 0;
role.gotoAndPlay(1, 3);
}, this);
/*** 本示例关键代码段结束 ***/
}
protected load(callback:Function):void {
var count:number = 0;
var self = this;
var check = function () {
count++;
if (count == 2) {
callback.call(self);
}
}
var loader = new egret.URLLoader();
loader.addEventListener(egret.Event.COMPLETE, function loadOver(e) {
var loader = e.currentTarget;
this._mcTexture = loader.data;
check();
}, this);
loader.dataFormat = egret.URLLoaderDataFormat.TEXTURE;
var request = new egret.URLRequest("resource/assets/mc/animation.png");
loader.load(request);
var loader = new egret.URLLoader();
loader.addEventListener(egret.Event.COMPLETE, function loadOver(e) {
var loader = e.currentTarget;
this._mcData = JSON.parse(loader.data);
check();
}, this);
loader.dataFormat = egret.URLLoaderDataFormat.TEXT;
var request = new egret.URLRequest("resource/assets/mc/animation.json");
loader.load(request);
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment