Squashed commit of the following:

commit b421082374
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Fri Dec 31 20:26:20 2021 +0800

    update specialthanks

commit 765a69294b
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Dec 14 19:10:03 2021 +0800

    fix ios goto

commit 8eb8c3ca72
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Dec 14 19:03:37 2021 +0800

    add event grade

commit ab705dd46c
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Dec 14 18:48:42 2021 +0800

    build version

commit a1e4232369
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Dec 14 18:47:05 2021 +0800

    change talent replace before property allocate

commit f4d7b3ae3c
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Dec 14 18:06:18 2021 +0800

    add event grade

commit 0567e40ddc
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 21:28:10 2021 +0800

    add particle

commit f17003925e
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 20:14:26 2021 +0800

    change ui

commit f8beda1d8f
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 19:08:30 2021 +0800

    change popup message ui

commit 915a2aa17d
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 18:34:29 2021 +0800

    new build

commit b5edabc104
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 18:18:46 2021 +0800

    add hint message

commit a143feadaf
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 17:57:31 2021 +0800

    fix copy bug

commit eab1975791
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 17:56:28 2021 +0800

    add save/load

commit acf9b92134
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Dec 2 14:35:33 2021 +0800

    add theme switch

commit 488a6054ab
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Wed Dec 1 18:30:36 2021 +0800

    fix uiManager bug

commit f0317eaf14
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Wed Dec 1 16:07:03 2021 +0800

    add message popup

commit eb02d1ee6f
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 21:22:54 2021 +0800

    change relocation

commit 60503eae47
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 19:27:16 2021 +0800

    change ScaleButton -> Laya.runtime.ScaleButton

commit 52ef5909c1
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 19:26:31 2021 +0800

    change ScaleButton -> Laya.runtime.ScaleButton

commit 0284f6aa71
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 19:05:24 2021 +0800

    config webpack

commit 0e272ffd99
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 13:17:41 2021 +0800

    add thanks

commit e1e2ab4701
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 28 11:40:21 2021 +0800

    add light theme

commit 4f55c00f86
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sat Nov 27 22:27:39 2021 +0800

    fix bug

commit 1d07bdfc46
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sat Nov 27 21:48:47 2021 +0800

    daily update

commit 52d6a0ca8f
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Wed Nov 24 23:10:04 2021 +0800

    daily update

commit f8dd720d4d
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Wed Nov 24 19:08:13 2021 +0800

    daily update

commit d088c1a862
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 21 21:41:46 2021 +0800

    remove useless

commit a711fcf3ed
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Nov 16 00:53:05 2021 +0800

    add achievement popup
    add page adaptive
    add talent extends

commit 05e02de3db
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sat Nov 13 01:24:04 2021 +0800

    add github and discord

commit bff0109cc5
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sat Nov 13 00:30:01 2021 +0800

    add trajectory auto mode

commit 54c04f65c2
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Fri Nov 12 19:54:31 2021 +0800

    fix property judge negative number bug

commit 660739530b
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Fri Nov 12 19:48:58 2021 +0800

    update achievement

commit c94e9e7433
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Thu Nov 11 21:37:45 2021 +0800

    update daily

commit c06cd9ea62
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Tue Nov 9 00:08:05 2021 +0800

    update daily

commit 2666983f89
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 7 23:00:22 2021 +0800

    add uiManager auto scan and load skin resource

commit 22fa5d755a
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Nov 7 22:17:04 2021 +0800

    update framework

commit f40698d63e
Author: Vick Scarlet <scarlet_vick@outlook.com>
Date:   Sun Oct 31 00:13:22 2021 +0800

    add laya
This commit is contained in:
Vick Scarlet
2021-12-31 20:31:26 +08:00
parent 99640a5813
commit 150c991648
372 changed files with 305714 additions and 5801 deletions

View File

@@ -0,0 +1,319 @@
var Browser = laya.utils.Browser;
var Composite = Matter.Composite;
var Events = Matter.Events;
var Bounds = Matter.Bounds;
var Common = Matter.Common;
var Vertices = Matter.Vertices;
var Vector = Matter.Vector;
var Sleeping = Matter.Sleeping;
var Axes = Matter.Axes;
var Body = Matter.Body;
var SAT = Matter.SAT;
var Contact = Matter.Contact;
var Pair = Matter.Pair;
var Detector = Matter.Detector;
var Grid = Matter.Grid;
var LayaRender = {};
(function()
{
var graphics,
spriteCon,
graphicsCon;
LayaRender.create = function(options)
{
var defaults = {
controller: LayaRender,
element: null,
canvas: null,
mouse: null,
options:
{
width: 800,
height: 600,
pixelRatio: 1,
background: '#fafafa',
wireframeBackground: '#222',
hasBounds: !!options.bounds,
enabled: true,
wireframes: true,
showSleeping: true,
showDebug: false,
showBroadphase: false,
showBounds: false,
showVelocity: false,
showCollisions: false,
showSeparations: false,
showAxes: false,
showPositions: false,
showAngleIndicator: false,
showIds: false,
showShadows: false,
showVertexNumbers: false,
showConvexHulls: false,
showInternalEdges: false,
showMousePosition: false
}
};
var render = Common.extend(defaults, options);
render.canvas = laya.renders.Render.canvas;
render.context = laya.renders.Render.context.ctx;
render.textures = {};
render.bounds = render.bounds ||
{
min:
{
x: 0,
y: 0
},
max:
{
x: Laya.stage.width,
y: Laya.stage.height
}
};
createContainer(render);
setBackground(render);
setPixelRatio();
return render;
};
function createContainer(render)
{
var con = render.container;
spriteCon = new Laya.Sprite();
graphicsCon = new Laya.Sprite();
render.spriteContainer = spriteCon;
render.graphicsContainer = graphicsCon;
con.addChild(spriteCon);
con.addChild(graphicsCon);
graphics = graphicsCon.graphics;
}
// 设置背景
function setBackground(render)
{
var bg = render.options.background;
// 纯色背景
if (bg.length == 7 && bg[0] == '#')
{
spriteCon.graphics.drawRect(
0, 0,
render.options.width, render.options.height,
bg);
}
// 图片背景
else
{
spriteCon.loadImage(bg);
}
}
function setPixelRatio()
{
var pixelRatio;
pixelRatio = 1;
Laya.Render.canvas.setAttribute('data-pixel-ratio', pixelRatio);
}
/**
* Renders the given `engine`'s `Matter.World` object.
* This is the entry point for all rendering and should be called every time the scene changes.
* @method world
* @param {engine} engine
*/
LayaRender.world = function(engine)
{
var render = engine.render,
world = engine.world,
options = render.options,
allConstraints = Composite.allConstraints(world),
bodies = Composite.allBodies(world),
constraints = [],
i;
// handle bounds
if (options.hasBounds)
{
var boundsWidth = render.bounds.max.x - render.bounds.min.x,
boundsHeight = render.bounds.max.y - render.bounds.min.y,
boundsScaleX = boundsWidth / options.width,
boundsScaleY = boundsHeight / options.height;
// filter out bodies that are not in view
for (i = 0; i < bodies.length; i++)
{
var body = bodies[i];
body.render.sprite.visible = Bounds.overlaps(body.bounds, render.bounds);
}
// filter out constraints that are not in view
for (i = 0; i < allConstraints.length; i++)
{
var constraint = allConstraints[i],
bodyA = constraint.bodyA,
bodyB = constraint.bodyB,
pointAWorld = constraint.pointA,
pointBWorld = constraint.pointB;
if (bodyA) pointAWorld = Vector.add(bodyA.position, constraint.pointA);
if (bodyB) pointBWorld = Vector.add(bodyB.position, constraint.pointB);
if (!pointAWorld || !pointBWorld)
continue;
if (Bounds.contains(render.bounds, pointAWorld) || Bounds.contains(render.bounds, pointBWorld))
constraints.push(constraint);
}
// transform the view
// context.scale(1 / boundsScaleX, 1 / boundsScaleY);
// context.translate(-render.bounds.min.x, -render.bounds.min.y);
}
else
{
constraints = allConstraints;
}
graphics.clear();
for (i = 0; i < bodies.length; i++)
LayaRender.body(engine, bodies[i]);
for (i = 0; i < constraints.length; i++)
LayaRender.constraint(engine, constraints[i]);
};
LayaRender.body = function(engine, body)
{
var render = engine.render,
bodyRender = body.render;
if (!bodyRender.visible)
{
return;
}
var spInfo = bodyRender.sprite;
var sp = body.sprite;
if (bodyRender.sprite && bodyRender.sprite.texture)
{
// initialize body sprite if not existing
if (!sp)
{
sp = body.sprite = createBodySprite(spInfo.xOffset, spInfo.yOffset);
sp.loadImage(spInfo.texture);
}
sp.scale(spInfo.xScale, spInfo.yScale);
sp.pos(body.position.x, body.position.y);
sp.rotation = body.angle * 180 / Math.PI;
}
else
{
var options = render.options;
// handle compound parts
for (k = body.parts.length > 1 ? 1 : 0; k < body.parts.length; k++)
{
part = body.parts[k];
if (!part.render.visible)
continue;
var fillStyle = options.wireframes ? null : part.render.fillStyle;
var lineWidth = part.render.lineWidth;
var strokeStyle = part.render.strokeStyle;
// part polygon
if (part.circleRadius)
{
graphics.drawCircle(part.position.x, part.position.y, part.circleRadius, fillStyle, strokeStyle, lineWidth);
}
else
{
var path = [];
path.push(part.vertices[0].x, part.vertices[0].y);
for (var j = 1; j < part.vertices.length; j++)
{
if (!part.vertices[j - 1].isInternal || showInternalEdges)
{
path.push(part.vertices[j].x, part.vertices[j].y);
}
else
{
path.push(part.vertices[j].x, part.vertices[j].y);
}
if (part.vertices[j].isInternal && !showInternalEdges)
{
path.push(part.vertices[(j + 1) % part.vertices.length].x, part.vertices[(j + 1) % part.vertices.length].y);
}
}
graphics.drawPoly(0, 0, path, fillStyle, strokeStyle, lineWidth);
}
}
}
};
LayaRender.constraint = function(engine, constraint)
{
var sx, sy, ex, ey;
if (!constraint.render.visible || !constraint.pointA || !constraint.pointB)
{
return;
}
var bodyA = constraint.bodyA,
bodyB = constraint.bodyB;
if (bodyA)
{
sx = bodyA.position.x + constraint.pointA.x;
sy = bodyA.position.y + constraint.pointA.y;
}
else
{
sx = constraint.pointA.x;
sy = constraint.pointA.y;
}
if (bodyB)
{
ex = bodyB.position.x + constraint.pointB.x;
ey = bodyB.position.y + constraint.pointB.y;
}
else
{
ex = constraint.pointB.x;
ey = constraint.pointB.y;
}
graphics.drawLine(
sx, sy, ex, ey,
constraint.render.strokeStyle,
constraint.render.lineWidth);
};
function createBodySprite(xOffset, yOffset)
{
var sp = new Laya.Sprite();
sp.pivot(xOffset, yOffset);
sp.pos(-9999, -9999);
spriteCon.addChild(sp);
return sp;
}
})();