# jbox2d **Repository Path**: zhyx147/jbox2d ## Basic Information - **Project Name**: jbox2d - **Description**: 实现C++ 物理引擎LiquidFun和Box2d的端口,可用于游戏开发,使物体的运动更加真实,让游戏场景看起来更具交互性,比如愤怒的小鸟 - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 3 - **Created**: 2023-08-17 - **Last Updated**: 2023-09-19 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # jbox2d ## 简介 > 用于游戏开发,使物体的运动更加真实,让游戏场景看起来更具交互性,比如愤怒的小鸟 ## 效果展示 ## 下载安装 ```shell ohpm install @ohos/box2d --save ``` OpenHarmony OpenHarmony ohpm环境配置等更多内容,请参考 如何安装 OpenHarmony ohpm 包 https://gitee.com/openharmony-tpc/docs/blob/master/OpenHarmony_har_usage.md ## 使用说明 ### jbox2d使用 ``` import * as box2d from '@ohos/box2d' ... aboutToAppear() { selectArr = []; for (let i: number = 0; i < g_testEntries.length; ++i) { let o = {}; o['value'] = g_testEntries[i].name; selectArr[i] = o;//初始化数据 } //循环调用渲染 this.init(); } private init() { setTimeout(inits, timeStep); } const inits = function (time) { setTimeout(loop, timeStep); } const loop = function (time) { setTimeout(loop, timeStep); app.SimulationLoop(time); } ... //动画切换 Select(selectArr) .selected(this.index) .value(selectArr[this.index].value) .font({ size: 20, weight: 200, family: 'serif', style: FontStyle.Normal }) .selectedOptionFont({ size: 30, weight: 300, family: 'serif', style: FontStyle.Normal }) .optionFont({ size: 20, weight: 200, family: 'serif', style: FontStyle.Normal }) .onSelect((index: number) => { this.index = index; if (app) { app.m_test_index = index; //加载动画 app.LoadTest(); } }) ``` ## 接口说明 ## 约束与限制 在下述版本验证通过: - DevEco Studio 版本:4.0 Beta2(4.0.3.411),OpenHarmony SDK:API10(4.0.10.2) ## 目录结构 ```` |---- jbox2d | |---- entry # 示例代码文件夹 | |----src |----main |----ets |----pages |----index.ets #效果主页面 |----Testbed |----Framework |----DebugDraw.ets #效果绘制具体实现 |----FullscreenUI.ts #全局页面初始化,是否启用粒子参数 |----Main.ets #效果绘制入口 |----ParticleEmitter.ts #粒子发射器 |----ParticleParameter.ts #粒子参数 |----Test.ets #canvas相关初始化设置 |----Tests #所有效果具体实现 |----Testbed.ts #对外接口 | |---- README.md # 安装使用方法 ```` ## 贡献代码 使用过程中发现任何问题都可以提 [Issue](https://gitee.com/openharmony-tpc/openharmony_tpc_samples/issues) 给我们,当然,我们也非常欢迎你给我们发 [PR](https://gitee.com/openharmony-tpc/openharmony_tpc_samples/pulls) 。 ## 开源协议 本项目基于 [MIT License](https://gitee.com/openharmony-tpc/openharmony_tpc_samples/blob/master/LICENSE) ,请自由地享受和参与开源。