hj [*][code]Laya.init(500,400,Laya.WebGL);[/code][/*] [*][code]createText();[/code][/*] [*][code]function createText(){[/code][/*] [*][code]this.txt = new Laya.Text();[/code][/*] [*][code]this.txt.overflow = Laya.Text.SCROLL;[/code][/*]this.txt.text = "Layabox是HTML5引擎技术提供商与优秀的游戏发行商,面向AS/JS/TS开发者提供HTML5开发技术方案!\n" ; [*][code]this.txt.size(200,100);[/code][/*] [*][code]this.txt.borderColor = "#ffff00";[/code][/*] [*][code]this.txt.fontSize = 20;[/code][/*] [*][code]this.txt.color = "#ffffff";[/code][/*] [*][code]Laya.stage.addChild(this.txt);[/code][/*] [*][code]this.txt.on(Laya.Event.MOUSE_DOWN,this,startScrollText);[/code][/*] [*][code]}[/code][/*]/*开始滚动文本*/ [*][code]function startScrollText(){[/code][/*] [*][code]this.prevX = this.txt.mouseX;[/code][/*] [*][code]this.prevY = this.txt.mouseY;[/code][/*] [*][code]Laya.stage.on(Laya.Event.MOUSE_MOVE,this,scrollText);[/code][/*] [*][code]Laya.stage.on(Laya.Event.MOUSE_UP,this,finishScrollText);[/code][/*] [*][code]}[/code][/*]/* 停止滚动文本 */ [*][code]function finishScrollText()[/code][/*] [*][code]{[/code][/*] [*][code]Laya.stage.off(Laya.Event.MOUSE_MOVE, this, this.scrollText);[/code][/*] [*][code]Laya.stage.off(Laya.Event.MOUSE_UP, this, this.finishScrollText);[/code][/*] [*][code]}[/code][/*]/* 鼠标滚动文本 */ [*][code]function scrollText()[/code][/*] [*][code]{[/code][/*] [*][code]var nowX = this.txt.mouseX;[/code][/*] [*][code]var nowY = this.txt.mouseY;[/code][/*] [*][code]this.txt.scrollX += this.prevX - nowX;[/code][/*] [*][code]this.txt.scrollY += this.prevY - nowY;[/code][/*] [*][code]this.prevX = nowX;[/code][/*] [*][code]this.prevY = nowY;[/code][/*] [*][code]}[/code][/*]