egret基础-计时器与Ticker(普通模式-单例模式)
先定义一个Timer类 用于案例计时器
class Timer extends egret.DisplayObjectContainer
{
public constructor()
{
super();
//创建一个计时器对象,每隔0.5秒执行一次,一共执行5次
var timer:egret.Timer = new egret.Timer(500,5);
//注册事件侦听器
timer.addEventListener(egret.TimerEvent.TIMER,this.timerFunc,this);
timer.addEventListener(egret.TimerEvent.TIMER_COMPLETE,this.timerComFunc,this);
//开始计时
timer.start();
}
private timerFunc()
{
console.log("计时");
}
private timerComFunc()
{
console.log("计时结束");
}
}
var _timer:Timer = new Timer();
this.addChild( _timer );
接下来是ticker类
class startTickerTest extends egret.DisplayObjectContainer {
private static shared: startTickerTest;
public static getInstance() {
if (!startTickerTest.shared) {
startTickerTest.shared = new startTickerTest();
}
return startTickerTest.shared;
}
public constructor() {
super();
this.once(egret.Event.ADDED_TO_STAGE, this.onLoad, this);
}
private star: egret.Bitmap;
private speed: number = 0.05;
private time: number = 0;
private onLoad(event: egret.Event) {
var star: egret.Bitmap = new egret.Bitmap(RES.getRes("egret_icon_png"));
this.addChild(star);
this.star = star;
this.time = egret.getTimer();
egret.startTick(this.moveStar, this);
}
private moveStar(timeStamp: number): boolean {
var now = timeStamp;
var time = this.time;
var pass = now - time;
console.log("moveStar: ", (1000 / pass).toFixed(5));
this.star.x += this.speed * pass;
if (this.star.x > 300)
egret.stopTick(this.moveStar, this);
this.time = now;
return false;
}
}
this.addChild( startTickerTest.getInstance() )
Desglymidodrine is dialyzable priligy generic
First, you want your partner s sperm to get as close as it can to your cervix, which means you need deep penetration priligy prescription
priligy alternative Colorado proud