mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 17:26:01 +08:00
Better scale.
This commit is contained in:
parent
378a413863
commit
fbd9a2057e
@ -44,8 +44,8 @@
|
|||||||
<div id="message"></div>
|
<div id="message"></div>
|
||||||
<div><canvas id="canvas" width="640" height="480"/></div>
|
<div><canvas id="canvas" width="640" height="480"/></div>
|
||||||
<br>
|
<br>
|
||||||
<input type="button" value="Spineboy" onclick="load('spineboy')">
|
<input type="button" value="Spineboy" onclick="load('spineboy', 0.6)">
|
||||||
<input type="button" value="Goblins" onclick="load('goblins')">
|
<input type="button" value="Goblins" onclick="load('goblins', 1)">
|
||||||
Click above to change the animation (Spineboy) or skin (Goblins).
|
Click above to change the animation (Spineboy) or skin (Goblins).
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
@ -54,52 +54,53 @@ var TurbulenzEngine = WebGLTurbulenzEngine.create({canvas: canvas});
|
|||||||
var graphicsDevice = TurbulenzEngine.createGraphicsDevice({});
|
var graphicsDevice = TurbulenzEngine.createGraphicsDevice({});
|
||||||
var draw2D = Draw2D.create({graphicsDevice: graphicsDevice});
|
var draw2D = Draw2D.create({graphicsDevice: graphicsDevice});
|
||||||
|
|
||||||
load("spineboy");
|
load("spineboy", 0.6);
|
||||||
//load("goblins");
|
//load("goblins", 1);
|
||||||
|
|
||||||
var skeletonName;
|
|
||||||
function load (name) {
|
|
||||||
skeletonName = name;
|
|
||||||
TurbulenzEngine.request("data/" + skeletonName + ".atlas", loadAtlas);
|
|
||||||
}
|
|
||||||
|
|
||||||
var atlas;
|
var atlas;
|
||||||
function loadAtlas (atlasText) {
|
|
||||||
var textureCount = 0;
|
|
||||||
atlas = new spine.Atlas(atlasText, {
|
|
||||||
load: function (page, path, atlas) {
|
|
||||||
textureCount++;
|
|
||||||
graphicsDevice.createTexture({
|
|
||||||
src: "data/" + path,
|
|
||||||
mipmaps: true,
|
|
||||||
onload: function (texture) {
|
|
||||||
page.rendererObject = texture;
|
|
||||||
page.width = texture.width;
|
|
||||||
page.height = texture.height;
|
|
||||||
atlas.updateUVs(page);
|
|
||||||
textureCount--;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
|
||||||
unload: function (texture) {
|
|
||||||
texture.destroy();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
function waitForTextures () {
|
|
||||||
if (!textureCount)
|
|
||||||
TurbulenzEngine.request("data/" + skeletonName + ".json", loadSkeletonData);
|
|
||||||
else
|
|
||||||
setTimeout(waitForTextures, 100);
|
|
||||||
}
|
|
||||||
waitForTextures();
|
|
||||||
}
|
|
||||||
|
|
||||||
var skeletonData;
|
var skeletonData;
|
||||||
function loadSkeletonData (skeletonText) {
|
var skeletonName;
|
||||||
var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
|
function load (name, scale) {
|
||||||
json.scale = 0.6;
|
skeletonName = name;
|
||||||
skeletonData = json.readSkeletonData(JSON.parse(skeletonText));
|
TurbulenzEngine.request("data/" + skeletonName + ".atlas", loadAtlas);
|
||||||
start();
|
|
||||||
|
function loadAtlas (atlasText) {
|
||||||
|
var textureCount = 0;
|
||||||
|
atlas = new spine.Atlas(atlasText, {
|
||||||
|
load: function (page, path, atlas) {
|
||||||
|
textureCount++;
|
||||||
|
graphicsDevice.createTexture({
|
||||||
|
src: "data/" + path,
|
||||||
|
mipmaps: true,
|
||||||
|
onload: function (texture) {
|
||||||
|
page.rendererObject = texture;
|
||||||
|
page.width = texture.width;
|
||||||
|
page.height = texture.height;
|
||||||
|
atlas.updateUVs(page);
|
||||||
|
textureCount--;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
unload: function (texture) {
|
||||||
|
texture.destroy();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
function waitForTextures () {
|
||||||
|
if (!textureCount)
|
||||||
|
TurbulenzEngine.request("data/" + skeletonName + ".json", loadSkeletonData);
|
||||||
|
else
|
||||||
|
setTimeout(waitForTextures, 100);
|
||||||
|
}
|
||||||
|
waitForTextures();
|
||||||
|
|
||||||
|
function loadSkeletonData (skeletonText) {
|
||||||
|
var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
|
||||||
|
json.scale = scale;
|
||||||
|
skeletonData = json.readSkeletonData(JSON.parse(skeletonText));
|
||||||
|
start();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function start () {
|
function start () {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user