[]GlowFilter和TimeLine/Tween一起用的问题
目标是实现一个物体的外发光闪动效果,demo如下,是直接从官方的glowfilter的demo改动过来的,执行以后没有效果
(function()
{
var Sprite = Laya.Sprite;
var Stage = Laya.Stage;
var GlowFilter = Laya.GlowFilter;
var Texture = Laya.Texture;
var Browser = Laya.Browser;
var Handler = Laya.Handler;
var WebGL = Laya.WebGL;
var Tween = Laya.Tween;
var Ease = Laya.Ease;
var HitArea = Laya.HitArea;
var TimeLine = Laya.TimeLine;
var apePath = "../../res/apes/monkey2.png";
var ape;
var splashSp = function(sp){
var glowFilter = new GlowFilter("#ffff00", 1, 0, 0);
sp.filters = [glowFilter];
var t = new TimeLine();
for(var i = 0; i < 5; i++){
t.to(glowFilter, {blur: 10}, 200, null, 0);
t.to(glowFilter, {blur: 1}, 200, null, 0);
}
t.on(Event.COMPLETE, this, function(){
sp.filters = null;
});
t.play(0, true);
};
(function()
{
// 不支持WebGL时自动切换至Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#232628";
Laya.loader.load(apePath, Handler.create(this, setup));
})();
function setup()
{
createApe();
applayFilter();
}
function createApe()
{
ape = new Sprite();
ape.loadImage(apePath);
var texture = Laya.loader.getRes(apePath);
ape.x = (Laya.stage.width - texture.width) / 2;
ape.y = (Laya.stage.height - texture.height) / 2;
Laya.stage.addChild(ape);
}
function applayFilter()
{
//创建一个发光滤镜
//var glowFilter = new GlowFilter("#ffff00", 10, 0, 0);
//设置滤镜集合为发光滤镜
//ape.filters = [glowFilter];
splashSp(ape);
}
})();
(function()
{
var Sprite = Laya.Sprite;
var Stage = Laya.Stage;
var GlowFilter = Laya.GlowFilter;
var Texture = Laya.Texture;
var Browser = Laya.Browser;
var Handler = Laya.Handler;
var WebGL = Laya.WebGL;
var Tween = Laya.Tween;
var Ease = Laya.Ease;
var HitArea = Laya.HitArea;
var TimeLine = Laya.TimeLine;
var apePath = "../../res/apes/monkey2.png";
var ape;
var splashSp = function(sp){
var glowFilter = new GlowFilter("#ffff00", 1, 0, 0);
sp.filters = [glowFilter];
var t = new TimeLine();
for(var i = 0; i < 5; i++){
t.to(glowFilter, {blur: 10}, 200, null, 0);
t.to(glowFilter, {blur: 1}, 200, null, 0);
}
t.on(Event.COMPLETE, this, function(){
sp.filters = null;
});
t.play(0, true);
};
(function()
{
// 不支持WebGL时自动切换至Canvas
Laya.init(Browser.clientWidth, Browser.clientHeight, WebGL);
Laya.stage.alignV = Stage.ALIGN_MIDDLE;
Laya.stage.alignH = Stage.ALIGN_CENTER;
Laya.stage.scaleMode = "showall";
Laya.stage.bgColor = "#232628";
Laya.loader.load(apePath, Handler.create(this, setup));
})();
function setup()
{
createApe();
applayFilter();
}
function createApe()
{
ape = new Sprite();
ape.loadImage(apePath);
var texture = Laya.loader.getRes(apePath);
ape.x = (Laya.stage.width - texture.width) / 2;
ape.y = (Laya.stage.height - texture.height) / 2;
Laya.stage.addChild(ape);
}
function applayFilter()
{
//创建一个发光滤镜
//var glowFilter = new GlowFilter("#ffff00", 10, 0, 0);
//设置滤镜集合为发光滤镜
//ape.filters = [glowFilter];
splashSp(ape);
}
})();
要回复问题请先登录
1 个回复
Laya_XS
赞同来自: