设为首页收藏本站|繁體中文

Project1

 找回密码
 注册会员
搜索
查看: 4253|回复: 3
打印 上一主题 下一主题

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

[复制链接]

Lv2.观梦者

梦石
0
星屑
719
在线时间
684 小时
注册时间
2009-5-29
帖子
461
跳转到指定楼层
1
发表于 2016-4-12 20:08:24 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

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

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

x
之前VA可以用stretch,JS应该怎么做呢?例如要把图标缩小成原来的0.5倍大小,难道只能另外制作一个图标文件吗?

Lv1.梦旅人

梦石
0
星屑
50
在线时间
1281 小时
注册时间
2006-8-27
帖子
590
2
发表于 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 认可答案

查看全部评分

回复 支持 反对

使用道具 举报

Lv2.观梦者

梦石
0
星屑
719
在线时间
684 小时
注册时间
2009-5-29
帖子
461
3
 楼主| 发表于 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
回复 支持 反对

使用道具 举报

Lv1.梦旅人

梦石
0
星屑
124
在线时间
18 小时
注册时间
2018-11-3
帖子
8
4
发表于 2018-11-14 19:44:28 | 只看该作者
wbsy8241 发表于 2016-4-12 20:50
rpg_core.js 能查到的方法啊
用blt 就可以了啊

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

使用道具 举报

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

本版积分规则

拿上你的纸笔,建造一个属于你的梦想世界,加入吧。
 注册会员
找回密码

站长信箱:[email protected]|手机版|小黑屋|无图版|Project1游戏制作

GMT+8, 2024-4-20 13:24

Powered by Discuz! X3.1

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表