# Tom Atom

Members

585

• #### Days Won

5

Tom Atom had the most liked content!

• Rank

• Website URL
SBC_Games

• Gender
Male

## Recent Profile Visitors

3,492 profile views

3. ## problem with space shooter lab example

Try this: if (cursors.up.isDown) { //this.physics.velocityFromRotation(ship.rotation, 600, ship.body.acceleration); ship.setVelocity(Math.cos(ship.rotation) * 600, Math.sin(ship.rotation) * 600); // 1 } else { ship.setAcceleration(0); ship.setVelocity(0,0); // 2 } In physics, you use acceleration to calculate new velocity and velocity to get new position. If you are driving car and accelerating for some time, your velocity increases. When you yake the foot out of the gas, your acceleration is 0, it does not increase velocity and your velocity is constant (unless there is inplemented something like friction or drag, which will slow you down). What you need is immediate change in velocity - it is commented as // 1. You can also add line // 2 to immediately stop ship if not holding up key... but it looks ugly (it is like you not only put foot out of gas, but stomped on break in the same time) Alternatively, you can change original line to this: this.physics.velocityFromRotation(ship.rotation, 600, ship.body.velocity);
4. ## possible to do long running algorithms?

No, there is no such time - your game is running in single thread and you are in risk, that browser will say your game is not responsive. If you do not want to split your long running task into smaller steps, then you have to use Web Workers as @stupot suggested - it will start separate thread. Look at here: https://www.w3schools.com/htmL/html5_webworkers.asp Unfortunatelly, Web Workers are not supported in old browsers (not a big problem), you have to have its task in separate file and you have to take care of communication between your game and Worker - postMessage / onmessage.
5. ## possible to do long running algorithms?

I was just solving this recently - AI thinking / computer generating in 2 games. for computer generating I had long time running loop. I changed it, that I record some variables, that allow me to re-enter method and continue where it ended last time. Then in my update() method I am calling it as long as it is generating. Something like bellow. Every frame I do as many steps as time "lastDelta * 0.9" allows me. Making only one step per frame would be bad - if you needed 10000 steps then it would take 166 seconds with 60 FPS: private _computerIsGenerating: boolean; // ------------------------------------------------------------------------- public update(): void { if (this._computerIsGenerating) { if (this.generate()) { this._computerIsGenerating = false; } } } // ------------------------------------------------------------------------- private generate(): boolean { let enterTime = this.time.time; let lastDelta = this.time.elapsed; do { // step generator let ready = this._generator.generateStep(); // found new puzzle if (ready) { return true; } } while (Date.now() - enterTime < lastDelta * 0.9); return false; } for AI thinking in another game, AI was doing lot of different things like board analysis, looking for some possible moves, etc. in one big loop. I broke it into states and whenever state is changed, I return and next frame I continue again with last state.

7. ## Spriter phaser 3 API

Hi, do you mean this: https://github.com/SBCGames/Spriter-Player-for-Phaser? If yes, I was about to make Phaser 3 version with some changes (like removing support for special binary format, that no one uses). But I decided to wait some time, as there is still lot of changes in engine with every new release.
8. ## Why game sometimes blinks while running in cordova webview?

@PixelPicoSean hmmm... it is Mali-400 (https://www.gsmarena.com/asus_zenfone_go_zc500tg-7368.php). Let us know, about results!
9. ## Does the particle system work in CANVAS?

Problem is connected with this bug: https://github.com/photonstorm/phaser/issues/3862 If I run, for example, this example: http://labs.phaser.io/view.html?src=src/game objects/particle emitter/angled emitter.js in Canvas, it hits problematic line in ParticleManagerCanvasRenderer.js (https://github.com/photonstorm/phaser/blob/master/src/gameobjects/particles/ParticleManagerCanvasRenderer.js#L106)
10. ## Why game sometimes blinks while running in cordova webview?

You can look at this topic: http://www.html5gamedevs.com/topic/25507-phaserwebgl-flickering-on-chrome-for-android-v53/ Setting preserveDrawingBuffer worked well, but for some devices, as I was reported by friends, it means big slowdown. Flickering is not caused by browser, but appears on devices with certain GPU. Here is list: Mali-400, Mali-450, Mediatek MT6582 List probably is not complete, so It would be good to add next GPUs if discovered. You can detect GPU on device like this: https://gist.github.com/cvan/042b2448fcecefafbb6a91469484cdf8 - I did not test it yet, but I am about to, as I have to make changes into one of our games. If you detected "bad" GPU, solution for Phaser 2 was to start game in Canvas rendering. Unfortunately Phaser 3 (3.11.0) is not ready for this yet. There are some fatures currently not supported in Canvas (tint - I added issue on GitHub with solution to support it at least for BitmapText - https://github.com/photonstorm/phaser/issues/3855 or at blog: http://sbcgames.io/category/blog/) and some are not working (RenderTexture - issue from yesterday - again with solution: https://github.com/photonstorm/phaser/issues/3862) So, you have two options: - use preserveDrawingBuffer and some devices may be really slow, - switch to canvas for some devices. If you do not need tint or render textures, you are happy and can switch without fixes. Otherwise, you may apply fixes and make your build.