phaser-arcade-physic模拟池塘放鱼自由游动及参数调节效果代码
代码语言:html
所属分类:动画
代码描述:phaser-arcade-physic模拟池塘放鱼自由游动及参数调节效果代码
代码标签: phaser-arcade-physic 模拟 池塘 放 鱼 自由 游动 参数 调节
下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开
<!DOCTYPE html> <html lang="en" > <head> <meta charset="UTF-8"> <meta name="viewport" content="width=1024"> <style> html, body { height: 100%; } body { margin: 0; padding: 0; background: #111; color: #eee; font: caption; } #version { position: absolute; left: 0; top: 0; padding: 0; background: rgba(0, 0, 0, 0.5) } </style> </head> <body > <footer><div id=version></div></footer> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/phaser-arcade-physics.min.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/colors.1.2.0.js"></script> <script type="text/javascript" src="//repo.bfw.wiki/bfwrepo/js/tweakpane.3.0.5.js"></script> <script > /* global colors, Phaser, Tweakpane */ const TIMESCALE = 1; const ZOOM = 1; const PHYSICS_STEPS_PER_SEC = 60; const DEBUG = false; const DEBUG_PHYSICS = false; const options = { alignWeight: 0.8, cohereWeight: 0.4, containRadius: 512, containTime: 1, containWeight: 0.6, maxForce: 120, maxSpeed: 60, nearRange: 60, quantity: 100, separateRange: 15, separateWeight: 0.2, wanderRadius: 0.25, wanderSpeed: 360, wanderStrength: 0.5, wanderWeight: 1 }; const debugOptions = { acceleration: false, align: true, cohere: true, contain: true, nearRange: false, separate: true, separateRange: false, velocity: false, wander: true, wanderRadius: true }; const { hexColors } = colors; const RandomAngle = Phaser.Math.Angle.Random; const FloatBetween = Phaser.Math.FloatBetween; const RotateTo = Phaser.Math.RotateTo; const DegToRad = Phaser.Math.DegToRad; const Remove = Phaser.Utils.Array.Remove; const Vector2 = Phaser.Math.Vector2; const Circle = Phaser.Geom.Circle; const Line = Phaser.Geom.Line; const ZERO = Phaser.Math.Vector2.ZERO; const bodyIsEnabled = function (body) { return body.enable === true; }; const bodyIsFish = function (body) { return body.gameObject.name === "fish"; }; const getBodyCenter = function (body) { return body.center; }; const getAvg = function (vectors, out) { out.reset(); for (const v of vectors) { out.add(v); } out.scale(1 / vectors.length); return out; }; const projectBody = function (body, time, pOut) { const { center, velocity } = body; return pOut.set(center.x + time * velocity.x, center.y + time * velocity.y); }; // Vector Phaser.Geom.Line.prototype.setFromPoints = function (a, b) { this.setTo(a.x, a.y, b.x, b.y.........完整代码请登录后点击上方下载按钮下载查看
网友评论0