Comments (3)
有 示例 项目吗?
from weapp-adapter.
//import * as PIXI from './libs/pixi';
import * as Matter from './libs/matter'
/**
-
游戏主函数
*/
export default class Main {
constructor() {
const A = {
x: 0,
y: 0
}const B = { x: 150, y: 0 } //window.Image = () => wx.createImage(); var canvas = wx.createCanvas(); canvas.width = 375; canvas.height = 667; this.context = canvas.getContext('2d') this.context.fillStyle = 'red' this.engine = Matter.Engine.create(); this.boxA = Matter.Bodies.rectangle(A.x, A.y, 30, 30); this.boxB = Matter.Bodies.rectangle(B.x, B.y, 60, 60); var ground = Matter.Bodies.rectangle(0, canvas.height - 60, canvas.width, 10, { isStatic: true }); Matter.World.add(this.engine.world, [this.boxA, this.boxB, ground]); var _f = ()=>{ this.context.clearRect(0, 0, canvas.width, canvas.height) Matter.Events.trigger(this.engine, 'tick', { timestamp: this.engine.timing.timestamp }) Matter.Engine.update(this.engine, this.engine.timing.delta) Matter.Events.trigger(this.engine, 'afterTick', { timestamp: this.engine.timing.timestamp }) //console.info(this.boxA.position) this.context.fillRect(this.boxA.position.x, this.boxA.position.y, 30, 30) this.context.fillRect(this.boxB.position.x, this.boxB.position.y, 60, 60) this.context.fillRect(0, canvas.height - 60, canvas.width, 10) // console.log('boxA', boxA.position); // console.log('boxB', boxB.position); } setInterval(_f.bind(this) , 50)
}
}
上面的代码要是用你们的代理插件将不能运行,关掉就能在微信小游戏里跑。
from weapp-adapter.
这个和 matter无关.
你不需要再创建 主canvas.
直接 var canvas = window.screencanvas;
就可以了.
你自己再调用 var canvas = wx.createCanvas();
时, 相当于创建了一个离屏canvas
from weapp-adapter.
Related Issues (20)
- Add set AttributeNS HOT 1
- 能在小程序不当中也使用adapter达到使用createjs等框架的目的吗 HOT 4
- AudioContext的问题 HOT 1
- THREE.js 网络的json模型下载到本地,用JSONLoader加载的时候提示 invalid url wxfile://XXX HOT 2
- 建议添加window.atob window.btoa HOT 3
- 作者大大好,请问,目前该框架对babylon.js的支持程度如何:) HOT 1
- 打一个广告,微信小游戏TS定义文件
- 我想用CustomEvent,在adapter里怎么写啊? HOT 3
- XMLHttpRequest 里 为何要用 weakMap? HOT 1
- 微信小游戏用threejs加载gltf模型
- 支持 DOMParser 接口 HOT 1
- Video 模拟考虑吗?
- 求问微信小程序的支持度 HOT 1
- 求助帖。如果我想用 babylon 画那个 离屏 canvas 的排行榜,怎么做? HOT 1
- indexdb 支持吗?
- onTouchMove问题
- 请问如何如何实现blob HOT 5
- 不太理解Node.js实现的真实作用? HOT 3
- XMLHttpRequest实现为什么要把ArrayBuffer转化为text? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from weapp-adapter.