我正试图创造一个简单的2D游戏,在这个游戏中,球正在向地面倾斜,受到一些障碍的影响,这些障碍将改变球的最终位置。
我正在使用MattriJS作为2D物理发动机,但实际上无法预测,我的球团总处于不同的最后位置。
是否有办法预断球会走的道路(经常),将球带入一个变数,并在我需要时把它装上同一条道路? 还是能够准确预测最后立场?
我正试图创造一个简单的2D游戏,在这个游戏中,球正在向地面倾斜,受到一些障碍的影响,这些障碍将改变球的最终位置。
我正在使用MattriJS作为2D物理发动机,但实际上无法预测,我的球团总处于不同的最后位置。
是否有办法预断球会走的道路(经常),将球带入一个变数,并在我需要时把它装上同一条道路? 还是能够准确预测最后立场?
I found a way to precompute instantly the path of the ball by calling manually Matter.Engine.update(engine)
and storing the position of my ball for each frame.
然后重新定位我的球体位,即:ball.isStatic = 真实;
,并在每一行程中人工移动:
Matter.Events.on(engine, "afterUpdate", () => {
if (positions.length > 0) {
Matter.Body.setPosition(ball, positions.shift());
}
});
Matter.js is deterministic. The only varying parameter is the deltas, the intervals between the ticks. The results will always be the same for a certain set of deltas.
然而,其精彩的导师,Matter.Render
,将照样的标度与显示的标度同步,window.requestAnimationFrame (
,因缺而异,因此每当你操作该代码时,三角洲会发生随机变化。
您可以人工使用<代码>。 Matter.Engine.update(engine, delta)。 在
一旦你在浏览器中处理事项,并且需要确定性,你就必须保留<代码>event.source.timing.lastDelta<>code>。
You can achieve it by:
采用相同的<代码>Engine的航道,供您在全球范围内保存。
Configuring _seed
and polyfiling trig functions:
import trigf from trigfills ;
import * as MatterJS from matter-js ;
trigf.setmaths();
MatterJS.Common._seed = 13579; // random value but always the same
export default MatterJS;
Set Options isFixed: real
while establishing Runner
Runner.create({
isFixed: true,
})
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.