如何获得createJS中位图图像的宽度?我需要它只改变图像的宽度来计算scaleX值。顺便说一下,有没有直接的方法来改变图像宽度,或者我需要使用scaleX属性?如何使用createJS获取位图的宽度?
使用库中的preloadJS预加载每个图像。
piecesArray[0].val = Math.floor(Math.random() * 50)
piecesArray[0].sym = new lib["a"+ piecesArray[0].val]()
model = new createjs.Bitmap(piecesArray[0].sym);
(function to change width)
stage.addChild(model.image)
我搜索使用控制台模型的所有变量和没有的getBounds(),也没有宽度,也没有高度,也不nominalBounds ...
附:这会发生什么,当我使用控制台
model = new createjs.Bitmap(new lib["c"+ 1]());
a {_listeners: null, _captureListeners: null, alpha: 1, cacheCanvas: null, cacheID: 0…}
console.log(model.image)
VM281:2 lib.c1 {spriteSheet: a, paused: true, currentAnimationFrame: 0, _animation: null, currentAnimation: null…}
undefined
console.log(model.image.width)
VM282:2 undefined
undefined
我已经试过了,但它说它是“未定义的” – Condward
然后在代码中的其他地方必须有一个错误。你应该确保'piecesArray [0] .sym'是一个有效的图像。 – derz