Mobile 平板电脑画架js+;使用sourceRect
我正在做一个移动项目(iPad和ios8.0.2); 我想对我的图片进行剪辑,以便从中显示较少的内容。 当在PC上显示时,它工作得非常好,而我们在平板电脑上测试时,截取的图像根本不显示。 你有什么建议吗Mobile 平板电脑画架js+;使用sourceRect,mobile,easeljs,Mobile,Easeljs,我正在做一个移动项目(iPad和ios8.0.2); 我想对我的图片进行剪辑,以便从中显示较少的内容。 当在PC上显示时,它工作得非常好,而我们在平板电脑上测试时,截取的图像根本不显示。 你有什么建议吗 this.background = new createjs.Bitmap('some_image.png'); //create a clipping of drawn image! var dims = this.background.getBounds();
this.background = new createjs.Bitmap('some_image.png');
//create a clipping of drawn image!
var dims = this.background.getBounds();
this.background.sourceRect = new createjs.Rectangle(0, 15, dims.width, dims.height);
this.background.x = 248;
this.background.y = 86;
this.stage.addChild(this.background);
我遇到了同样的问题。我已经放弃使用位图来剪裁图像。我找到了另一个解决方案,这里是“
“。祝你好运。我正在计算,代码如下:
var img, stage;
function init() {
//wait for the image to load
img = new Image();
img.onload = handleImageLoad;
img.src = "./res/image.png";
}
function handleImageLoad(evt) {
// create a new stage and point it at our canvas:
stage = new createjs.Stage("canvas");
// create a new Bitmap, and slice out one image from the sprite sheet:
var bmp = new createjs.Bitmap(evt.target).set({x:200, y:200});
bmp.sourceRect = new createjs.Rectangle(916, 101, 84, 84);
//x,y,width,height
stage.addChild(bmp);
stage.update();
}
例如:
您正在使用phonegap吗?似乎它在preloadjs中工作得不太好。看看这个:嗨,renatop,我既不使用phonegap也不使用preloadjsoh,你是在等待图像在使用前完全加载吗?如果不是,那可能是你的问题。是的,它的加载和缓存也只有在iOS 8.0.2guys中才会发生这种情况,请在投票时解释你自己。。。我认为这是一个很好的迂回解决方案,不管这是一个迂回解决方案,我认为这是一个很好的迂回解决问题的方法。正确地绘制精灵,位图(非Cropped),但裁剪图像更容易使用“随机”精灵,因为答案是关于位图和SourceRect的,但不适用于我们的情况