小程序
小游戏
企业微信
微信支付
扫描小程序码分享
请问这个问题怎么办啊?(呜呜呜,我好卑微,根本看不懂~)
2 个回答
加粗
标红
插入代码
插入链接
插入图片
上传视频
import {ResourceLoader} from "./base/ResourcrLoader.js"; import {DataStore} from "./base/DataStorm.js"; import {Background} from "./runtime/Background.js"; import {Director} from "./Director.js"; import {Land} from "./runtime/Land.js"; // function createRecycleContext() { // return undefined; // } //let ctx = canvas.getContext('2d'); //const ctx = createRecycleContext(); export class Main{ constructor() { this.canvas = document.getElementById('game_canvas'); //准备好画布 this.ctx = this.canvas.getContext('2d'); //准备好上下文对象 this.dataStore = DataStore.getInstance(); //找到变量存储器 this.director = Director.getInstance(); //找到导演类 const loader = ResourceLoader.create(); //创建资源加载器 loader.onload(map=>this.onResourceFirstLoad(map)); // let image = new Image(); // image.src = './images/background1.png'; // image.onload = ()=>{ // this.ctx.drawImage(image, // 0,0, // image.width,image.height, // 0,0, // image.width,image.height); // } } onResourceFirstLoad(map){ //第一次完成加载时,将canvas,context,map对象存入变量存贮器中 //console.log(map) //let ctx = createRecycleContext(); this.dataStore = DataStore.getInstance(); this.dataStore.ctx = this.ctx ; this.dataStore.canvas = this.canvas; this.dataStore.images = map; //DataStore中的images变量储存的是图片对象 this.init(); } init(){ //将每个精灵放入DataStore中 this.dataStore.put('background1',Background) .put('land',Land); this.director.run(); } }
你好,麻烦通过点击下方“反馈信息”按钮,提供出现问题的。
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html 能否按照网址里面的操作制作简单的代码片段给我们进行排查问题?
关注后,可在微信内接收相应的重要提醒。
请使用微信扫描二维码关注 “微信开放社区” 公众号
import {ResourceLoader} from "./base/ResourcrLoader.js"; import {DataStore} from "./base/DataStorm.js"; import {Background} from "./runtime/Background.js"; import {Director} from "./Director.js"; import {Land} from "./runtime/Land.js"; // function createRecycleContext() { // return undefined; // } //let ctx = canvas.getContext('2d'); //const ctx = createRecycleContext(); export class Main{ constructor() { this.canvas = document.getElementById('game_canvas'); //准备好画布 this.ctx = this.canvas.getContext('2d'); //准备好上下文对象 this.dataStore = DataStore.getInstance(); //找到变量存储器 this.director = Director.getInstance(); //找到导演类 const loader = ResourceLoader.create(); //创建资源加载器 loader.onload(map=>this.onResourceFirstLoad(map)); // let image = new Image(); // image.src = './images/background1.png'; // image.onload = ()=>{ // this.ctx.drawImage(image, // 0,0, // image.width,image.height, // 0,0, // image.width,image.height); // } } onResourceFirstLoad(map){ //第一次完成加载时,将canvas,context,map对象存入变量存贮器中 //console.log(map) //let ctx = createRecycleContext(); this.dataStore = DataStore.getInstance(); this.dataStore.ctx = this.ctx ; this.dataStore.canvas = this.canvas; this.dataStore.images = map; //DataStore中的images变量储存的是图片对象 this.init(); } init(){ //将每个精灵放入DataStore中 this.dataStore.put('background1',Background) .put('land',Land); this.director.run(); } }
https://developers.weixin.qq.com/miniprogram/dev/devtools/minicode.html 能否按照网址里面的操作制作简单的代码片段给我们进行排查问题?
import {DataStore} from "./base/DataStorm.js";
import {Background} from "./runtime/Background.js";
import {Director} from "./Director.js";
import {Land} from "./runtime/Land.js";
// function createRecycleContext() {
// return undefined;
// }
//let ctx = canvas.getContext('2d');
//const ctx = createRecycleContext();
export class Main{
constructor() {
this.canvas = document.getElementById('game_canvas'); //准备好画布
this.ctx = this.canvas.getContext('2d'); //准备好上下文对象
this.dataStore = DataStore.getInstance(); //找到变量存储器
this.director = Director.getInstance(); //找到导演类
const loader = ResourceLoader.create(); //创建资源加载器
loader.onload(map=>this.onResourceFirstLoad(map));
// let image = new Image();
// image.src = './images/background1.png';
// image.onload = ()=>{
// this.ctx.drawImage(image,
// 0,0,
// image.width,image.height,
// 0,0,
// image.width,image.height);
// }
}
onResourceFirstLoad(map){ //第一次完成加载时,将canvas,context,map对象存入变量存贮器中
//console.log(map)
//let ctx = createRecycleContext();
this.dataStore = DataStore.getInstance();
this.dataStore.ctx = this.ctx ;
this.dataStore.canvas = this.canvas;
this.dataStore.images = map; //DataStore中的images变量储存的是图片对象
this.init();
}
init(){ //将每个精灵放入DataStore中
this.dataStore.put('background1',Background)
.put('land',Land);
this.director.run();
}
}