1、主界面背景动画
1.1底部;
1.2根据场景:
云通过预制件附带动画效果,动态加载
星星、雪花通过粒子效果动态加载
星星、雪花通过粒子效果动态加载
云动态加载,动态设置移动和销毁
setLocalZOrder(1.9版本代码,2.0.1后变为zindex属性),越大越后渲染,即放在前排,Canvas下无效,node需要放在整个Scene场景中。
动态加载atlas resource
let scene = cc.director.getScene();
let dynode = new cc.Node("cloudsprite "+ cc.director.getScene().childrenCount);
let dycloud = dynode.addComponent(cc.Sprite);
cc.loader.loadRes("bgAtlas", cc.SpriteAtlas, function (err, bgAtlas) {
let frame = bgAtlas.getSpriteFrame(bgcloudurl);
dycloud.spriteFrame = frame;
});
let randx = cc.winSize.width + 220;
let randy =cc.winSize.height * (1 - cc.random0To1() / 3);
let randpos = cc.p(randx, randy);
let endpos = cc.p(-220, randy);
dynode.setPosition(randpos);
dynode.parent = scene;
多个动画按序执行,适合移动完成后,销毁自己。如下:
let movplan = cc.moveTo(7, endpos);
let movend = cc.callFunc(dynode.removeFromParent, dynode);
let cloudAct = cc.sequence(movplan, movend);
dynode.runAction(movplan);
2、云朵动态生成
this.schedule(this.update5Clouds, 2);
update5Clouds (dt)
{
let tmpCloud = this.newClouds(5);
}