Javascript 游戏期间RNGE物理更新速度
我正在React Native game Engine(RNGE)中做一个flappy bird游戏,我正在寻找一种方法来更新整个游戏的速度,以便游戏变得越来越困难 下面对速度进行了注释,其中定义了向左移动管道的速度。我曾尝试使用钩子上下文,但当物理函数在deltatime被调用时,如果我理解正确,游戏会出现错误消息“无效钩子调用”,从而崩溃(?) 关于我可以尝试什么,有什么专业建议吗 我刚开始使用RNGE,所以我真的很感谢所有能给我的帮助Javascript 游戏期间RNGE物理更新速度,javascript,reactjs,physics,Javascript,Reactjs,Physics,我正在React Native game Engine(RNGE)中做一个flappy bird游戏,我正在寻找一种方法来更新整个游戏的速度,以便游戏变得越来越困难 下面对速度进行了注释,其中定义了向左移动管道的速度。我曾尝试使用钩子上下文,但当物理函数在deltatime被调用时,如果我理解正确,游戏会出现错误消息“无效钩子调用”,从而崩溃(?) 关于我可以尝试什么,有什么专业建议吗 我刚开始使用RNGE,所以我真的很感谢所有能给我的帮助 import React from "rea
import React from "react";
import Matter from "matter-js";
const Physics = (entities, { touches, time }) => {
let engine = entities.physics.engine;
let bird = entities.bird.body;
touches
.filter((t) => t.type === "press")
.forEach((t) => {
Matter.Body.setVelocity(bird, {
x: bird.velocity.x,
y: -5,
});
});
for (let i = 1; i <= 4; i++) {
//if the pipe is moving off the screen, change x-position to the right again
if (
entities["pipe" + i].body.position.x <=
-1 * (Constants.PIPE_WIDTH / 2)
) {
Matter.Body.setPosition(entities["pipe" + i].body, {
x: Constants.MAX_WIDTH * 2 - Constants.PIPE_WIDTH / 2,
y: entities["pipe" + i].body.position.y,
});
} else {
//change pipe-position in delta time updates
Matter.Body.translate(entities["pipe" + i].body, {
x: -1, //need this value to slowly decrease during the game so the pipes move faster
y: 0,
});
}
}
Matter.Engine.update(engine, time.delta);
return entities;
};
export default Physics;
从“React”导入React;
从“物质js”导入物质;
常量物理=(实体,{touch,time})=>{
让engine=entities.physics.engine;
让bird=entities.bird.body;
触碰
.filter((t)=>t.type==“按”)
.forEach((t)=>{
物质。身体。设定速度(鸟{
鸟,速度,x,
y:-5,
});
});
for(设i=1;i