Eva.js互动游戏引擎

联合创作 · 2023-09-27 18:46

Eva.js 是一款专注于开发游戏化项目的游戏引擎,提供了游戏化项目开发中最常用、最基础的功能,让开发前端游戏化变得轻而易举。Eva.js 还提供高效的游戏运行时、渲染能力,可实现复杂的游戏化场景。


Eva.js 基于 ECS 设计模式,可自由扩展引擎功能,构建更繁荣的生态系统。



示例代码



<canvas id="canvas" ></canvas>


import { Game, GameObject, resource, RESOURCE_TYPE } from '@eva/eva.js';
import { RendererSystem } from '@eva/plugin-renderer';
import { Img, ImgSystem } from '@eva/plugin-renderer-img';

resource.addResource([
{
name: 'imageName',
type: RESOURCE_TYPE.IMAGE,
src: {
image: {
type: 'png',
url:
'https://gw.alicdn.com/tfs/TB1DNzoOvb2gK0jSZK9XXaEgFXa-658-1152.webp',
},
},
preload: true,
},
]);

const game = new Game({
systems: [
new RendererSystem({
canvas: document.querySelector('#canvas'),
width: 750,
height: 1000,
}),
new ImgSystem(),
],
});

const image = new GameObject('image', {
size: { width: 750, height: 1319 },
origin: { x: 0, y: 0 },
position: {
x: 0,
y: -319,
},
anchor: {
x: 0,
y: 0,
},
});

image.addComponent(
new Img({
resource: 'imageName',
})
);

game.scene.addChild(image);

浏览 33
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑 分享
举报