抱歉,您的浏览器不支持访问该网站,建议更换更新版本的浏览器,例如Chrome/Firefox/Safari等
首页
分享
登录
分享
登录
关于Xnote
回到
顶部
文档查看
分享链接:
复制
根目录
/
我的项目
/
quarkjs引擎
分享中
标签
机械星球
js
文档
公开
# 类关系 ``` EventDispatcher | |-- ImageLoader | |-- Audio | `--DisplayObject [x,y,width,height] | |-- DisplayObjectContainer | | | |-- Stage | | | `-- Button | |-- Bitmap [rectX, rectY, width, height] | | | `-- MovieClip | |-- Text | `-- Graphics Context | |-- CanvasContext | `-- DOMContext Drawable Matrix Rectangle ``` # Quark - Quark.toggleDebugRect = function(stage) 切换调试状态,要先设置 stage.debug=true # DisplayObject - alpha,透明度 # Bitmap.setRect ``` Bitmap.prototype.setRect = function(rect) { this.rectX = rect[0]; this.rectY = rect[1]; this.rectWidth = this.width = rect[2]; this.rectHeight = this.height = rect[3]; }; ``` # 更新函数 ``` Stage.prototype.step = function(timeInfo) { if(this.paused) return; this._update(timeInfo); this._render(this.context); }; ``` # 问题 - quarkjs在运行过程中removeChild是否有问题 - 如果在render过程中child被移除,会有问题 ``` DisplayObjectContainer.prototype.render = function(context) { DisplayObjectContainer.superClass.render.call(this, context); for(var i = 0, len = this.children.length; i < len; i++) { var child = this.children[i]; child._render(context); } }; DisplayObjectContainer.prototype._update = function(timeInfo) { //先更新容器本身的数据,再更新子元素的数据 var result = true; if(this.update != null) result = this.update(timeInfo); if(result === false) return; var copy = this.children.slice(0); for(var i = 0, len = copy.length; i < len; i++) { var child = copy[i]; child._depth = i + 1; child._update(timeInfo); } }; ``` # Canvas API ``` context.drawImage(img,sx,sy,swidth,sheight,x,y,width,height) 参数值 参数 描述 img 规定要使用的图像、画布或视频。 sx 可选。开始剪切的 x 坐标位置。 sy 可选。开始剪切的 y 坐标位置。 swidth 可选。被剪切图像的宽度。 sheight 可选。被剪切图像的高度。 x 在画布上放置图像的 x 坐标位置。 y 在画布上放置图像的 y 坐标位置。 width 可选。要使用的图像的宽度。(伸展或缩小图像) height 可选。要使用的图像的高度。(伸展或缩小图像) ```
game 创建于 2017-05-15 更新于 2019-11-11
加载中...
应用列表