Better scale.

This commit is contained in:
NathanSweet 2014-11-13 01:17:45 +01:00
parent 378a413863
commit fbd9a2057e

View File

@ -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)">
&nbsp; &nbsp; &nbsp; Click above to change the animation (Spineboy) or skin (Goblins). &nbsp; &nbsp; &nbsp; Click above to change the animation (Spineboy) or skin (Goblins).
<script> <script>
@ -54,17 +54,17 @@ 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 skeletonData;
var skeletonName;
function load (name, scale) {
skeletonName = name;
TurbulenzEngine.request("data/" + skeletonName + ".atlas", loadAtlas);
function loadAtlas (atlasText) {
var textureCount = 0; var textureCount = 0;
atlas = new spine.Atlas(atlasText, { atlas = new spine.Atlas(atlasText, {
load: function (page, path, atlas) { load: function (page, path, atlas) {
@ -85,6 +85,7 @@ function loadAtlas (atlasText) {
texture.destroy(); texture.destroy();
} }
}); });
function waitForTextures () { function waitForTextures () {
if (!textureCount) if (!textureCount)
TurbulenzEngine.request("data/" + skeletonName + ".json", loadSkeletonData); TurbulenzEngine.request("data/" + skeletonName + ".json", loadSkeletonData);
@ -92,14 +93,14 @@ function loadAtlas (atlasText) {
setTimeout(waitForTextures, 100); setTimeout(waitForTextures, 100);
} }
waitForTextures(); waitForTextures();
}
var skeletonData; function loadSkeletonData (skeletonText) {
function loadSkeletonData (skeletonText) {
var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas)); var json = new spine.SkeletonJson(new spine.AtlasAttachmentLoader(atlas));
json.scale = 0.6; json.scale = scale;
skeletonData = json.readSkeletonData(JSON.parse(skeletonText)); skeletonData = json.readSkeletonData(JSON.parse(skeletonText));
start(); start();
}
}
} }
function start () { function start () {