createjs实现烟花绽放动画效果
代码语言:html
所属分类:粒子
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title> - Star fireworks spike</title> <style> body { background: #000; margin: 0; overflow: hidden; } #target { background: #222; display: block; } #logo { position: absolute; bottom: 1%; right: 1%; } </style> </head> <body translate="no"> <canvas id="target" width="1280" height="720"></canvas> <script type="text/javascript" src="http://repo.bfw.wiki/bfwrepo/js/createjs.min.js"></script> <script> var c = createjs, stage = new c.Stage("target"), t=0; var w = stage.canvas.width, h=stage.canvas.height var colors=["red", "green", "blue","orange","purple"], r=16, rows=5, cols=8; var grid, nextT=0, frame=-1, particles; init(); function init() { grid = buildGrid(); var clear = stage.addChild(new c.Shape()); clear.graphics.f("rgba(0,0,0,0.05)").dr(0,0,w,h); particles = stage.addChild(new c.Container()); stage.autoClear = false; c.Ticker.timingMode = c.Ticker.RAF; c.Ticker.on("tick", tick); } function tick(evt) { t += evt.delta; if (t > nextT) { frame = (frame+1)%cols; drawFrame(grid[frame]); nextT = t+200; } update(evt.delta/16); } function update(m) { var parts = particles.children; for (var i=parts.length-1; i>=0; i--) { var p = parts[i]; if (p.alpha < 1) { p.alpha += 0.01; } p.x +.........完整代码请登录后点击上方下载按钮下载查看
网友评论0