|Published (Last):||21 November 2018|
|PDF File Size:||18.38 Mb|
|ePub File Size:||2.76 Mb|
|Price:||Free* [*Free Regsitration Required]|
The scene property of the configuration object will be covered in more detail further on in this tutorial. If you’ve gone through the Getting Started Guide you will have downloaded Phaser and got everything set-up and ready to code. Although that isn’t very interesting, it’s useful for understanding the concepts of web workers. Communication between a javascfipt and its parent page is done using an event model and the postMessage method.
Making your first Phaser 3 game: Part 1 – Introduction – Learn – Phaser
What if you want to create your worker script on the fly, or create a self-contained page without having to create separate worker files? Some of these include browser compatibility, static typing, accessibility, and performance.
The message payload in this case ‘Hello World’ is accessible in Event. Hence, the failure will be due to cross origin restrictions. Download the resources for this tutorial and unzip javascrript into your web root.
Although this particular example isn’t very exciting, it demonstrates that postMessage is also your means for passing data back to the main thread. The first argument doesn’t have to be an ArrayBuffer by the way. The worker simply returns the message that is passed to it. With Transferable Objects, data is transferred from one context to another.
However, when passing these types of data using postMessagea copy is still made.
Making your first Phaser 3 game
Assuming your main app is running from http: You can explicitly release a Blob URLs by passing it to window.
Structured cloning is great, but a copy can take hundreds of milliseconds. This is great for further breaking up large tasks at runtime. Game object is assigned to a slapok variable called game and the configuration object is passed to it. The width and height properties set the size of the canvas element that Phaser will create.
For example, it can be a JSON object:.
As a result, the code that they execute needs to be contained in a separate file. If you’re creating many Blob URLs, it’s a good idea to release references that are no longer needed. This will insure the external script is imported from the same origin. Thus, the previous example could also be written as:.