feat: 星域故事汇小游戏初始版本
This commit is contained in:
37
client/js/libs/weapp-adapter.js
Normal file
37
client/js/libs/weapp-adapter.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* 微信小游戏适配器
|
||||
*/
|
||||
|
||||
// 获取系统信息
|
||||
const systemInfo = wx.getSystemInfoSync();
|
||||
const screenWidth = systemInfo.windowWidth;
|
||||
const screenHeight = systemInfo.windowHeight;
|
||||
const devicePixelRatio = systemInfo.pixelRatio;
|
||||
|
||||
// 创建主Canvas
|
||||
const canvas = wx.createCanvas();
|
||||
canvas.width = screenWidth * devicePixelRatio;
|
||||
canvas.height = screenHeight * devicePixelRatio;
|
||||
|
||||
// 设置全局变量
|
||||
GameGlobal.canvas = canvas;
|
||||
GameGlobal.screenWidth = screenWidth;
|
||||
GameGlobal.screenHeight = screenHeight;
|
||||
GameGlobal.devicePixelRatio = devicePixelRatio;
|
||||
|
||||
// Image适配
|
||||
GameGlobal.Image = function() {
|
||||
return wx.createImage();
|
||||
};
|
||||
|
||||
// Audio适配
|
||||
GameGlobal.Audio = function() {
|
||||
return wx.createInnerAudioContext();
|
||||
};
|
||||
|
||||
export default {
|
||||
canvas,
|
||||
screenWidth,
|
||||
screenHeight,
|
||||
devicePixelRatio
|
||||
};
|
||||
Reference in New Issue
Block a user