mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 23:34:53 +08:00
Fixed additive blending demo, calculations take scrolling into account.
This commit is contained in:
parent
923c6c19f2
commit
5994c347ea
@ -6,11 +6,9 @@
|
||||
<script src="https://code.jquery.com/jquery-3.1.0.min.js"></script>
|
||||
<script src="utils.js"></script>
|
||||
<script src="additiveblending.js"></script>
|
||||
<body>
|
||||
<body style="margin: 0; padding: 0;">
|
||||
|
||||
<center>
|
||||
<div class="aspect standalone"></div>
|
||||
</center>
|
||||
<div style="margin: 0 auto;" class="aspect standalone"></div>
|
||||
|
||||
<script>
|
||||
spineDemos.init();
|
||||
|
||||
@ -15,6 +15,9 @@ var additiveBlendingDemo = function(canvas, bgColor) {
|
||||
var isPlaying = true;
|
||||
|
||||
var left, right, up, down;
|
||||
var cursor;
|
||||
|
||||
var clientMouseX = 0, clientMouseY = 0;
|
||||
|
||||
var DEMO_NAME = "AdditiveBlendingDemo";
|
||||
|
||||
@ -35,6 +38,8 @@ var additiveBlendingDemo = function(canvas, bgColor) {
|
||||
assetManager.loadText(DEMO_NAME, "atlas2.atlas");
|
||||
assetManager.loadJson(DEMO_NAME, "demos.json");
|
||||
timeKeeper = new spine.TimeKeeper();
|
||||
|
||||
cursor = document.getElementById("cursor");
|
||||
}
|
||||
|
||||
function loadingComplete () {
|
||||
@ -83,6 +88,7 @@ var additiveBlendingDemo = function(canvas, bgColor) {
|
||||
function calculateBlend (x, y, isPageCoords) {
|
||||
if (isPageCoords) {
|
||||
var canvasBounds = canvas.getBoundingClientRect();
|
||||
console.log(canvasBounds.x + ", " + canvasBounds.y + ", " + x + ", " + y);
|
||||
x = Math.max(0, Math.min(canvasBounds.width, x - canvasBounds.x));
|
||||
y = Math.max(0, Math.min(canvasBounds.height, y - canvasBounds.y));
|
||||
}
|
||||
@ -97,7 +103,8 @@ var additiveBlendingDemo = function(canvas, bgColor) {
|
||||
function setupInput () {
|
||||
if (!isMobileDevice()) {
|
||||
document.addEventListener("mousemove", function (event) {
|
||||
calculateBlend(event.clientX, event.clientY, true);
|
||||
clientMouseX = event.clientX;
|
||||
clientMouseY = event.clientY;
|
||||
}, false);
|
||||
} else {
|
||||
var input = new spine.webgl.Input(canvas);
|
||||
@ -124,6 +131,10 @@ var additiveBlendingDemo = function(canvas, bgColor) {
|
||||
}
|
||||
|
||||
function render () {
|
||||
if (!isMobileDevice()) {
|
||||
calculateBlend(clientMouseX, clientMouseY, true);
|
||||
}
|
||||
|
||||
timeKeeper.update();
|
||||
var delta = timeKeeper.delta;
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user