查看: 4920|回复: 3

[已经解决] 如何做到图片缩放?

[复制链接]
梦石
0
星屑
724
在线时间
685 小时
注册时间
2009-5-29
回帖
332
发表于 2016-4-12 20:08:24 | 显示全部楼层 |阅读模式

加入我们,或者,欢迎回来。

您需要 登录 才可以下载或查看,没有账号?注册会员

×
之前VA可以用stretch,JS应该怎么做呢?例如要把图标缩小成原来的0.5倍大小,难道只能另外制作一个图标文件吗?
梦石
0
星屑
50
在线时间
1281 小时
注册时间
2006-8-27
回帖
550
发表于 2016-4-12 20:50:56 | 显示全部楼层
  1. /**
  2. * Performs a block transfer.
  3. *
  4. * @method blt
  5. * @param {Bitmap} source The bitmap to draw
  6. * @param {Number} sx The x coordinate in the source
  7. * @param {Number} sy The y coordinate in the source
  8. * @param {Number} sw The width of the source image
  9. * @param {Number} sh The height of the source image
  10. * @param {Number} dx The x coordinate in the destination
  11. * @param {Number} dy The y coordinate in the destination
  12. * @param {Number} [dw=sw] The width to draw the image in the destination
  13. * @param {Number} [dh=sh] The height to draw the image in the destination
  14. */
  15. Bitmap.prototype.blt = function(source, sx, sy, sw, sh, dx, dy, dw, dh) {
  16.     dw = dw || sw;
  17.     dh = dh || sh;
  18.     if (sx >= 0 && sy >= 0 && sw > 0 && sh > 0 && dw > 0 && dh > 0 &&
  19.             sx + sw <= source.width && sy + sh <= source.height) {
  20.         this._context.globalCompositeOperation = 'source-over';
  21.         this._context.drawImage(source._canvas, sx, sy, sw, sh, dx, dy, dw, dh);
  22.         this._setDirty();
  23.     }
  24. };
复制代码
rpg_core.js 能查到的方法啊
用blt 就可以了啊

评分

参与人数 1星屑 +166 收起 理由
余烬之中 + 166 认可答案

查看全部评分

回复

使用道具 举报

梦石
0
星屑
724
在线时间
685 小时
注册时间
2009-5-29
回帖
332
 楼主| 发表于 2016-4-28 11:41:04 | 显示全部楼层
wbsy8241 发表于 2016-4-12 20:50
rpg_core.js 能查到的方法啊
用blt 就可以了啊

好吧,之前没注意看- -
谢谢~

点评

其实对于单个 bitmap 的情况建议放在 sprite 里面然后使用 Sprite#scale,详情看 F1 的相关部分  发表于 2016-4-28 12:45
回复

使用道具 举报

梦石
0
星屑
124
在线时间
18 小时
注册时间
2018-11-3
回帖
8
发表于 2018-11-14 19:44:28 | 显示全部楼层
wbsy8241 发表于 2016-4-12 20:50
rpg_core.js 能查到的方法啊
用blt 就可以了啊

大佬能否详解一下怎么用?新人感激不敬
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册会员

本版积分规则

Powered by Discuz! X5.0 © 2001-2026 Discuz! Team.

在本版发帖返回顶部