This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This script is designed to detect if an unintended webview reload has occurred due to high memory usage. | |
* It uses the localStorage to store a 'tick' value which is the timestamp of the last frame. | |
* It also uses a 'safe-reload' flag to determine if the reload was intentional. | |
*/ | |
if(localStorage.getItem('safe-reload') === 'true' || !localStorage.getItem('tick')) { | |
// If 'safe-reload' is set to true or 'tick' is not present in localStorage, it means: | |
// - The reload was intentional (safe-reload is true) | |
// - This is the first load (tick is not present) | |
// In both cases, we clear the 'safe-reload' flag. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function makeOpenAICall({ style, theme }: { style: string; theme: string }) { | |
/** | |
* set up a schema for the result using zod (https://www.npmjs.com/package/zod). we can then use this schema to tell open ai how to format the result | |
* it will use the descriptions to figure our what to but in each property.. | |
* | |
*/ | |
const resultSchema = z.object({ | |
name: z.string().describe('The name of the game'), | |
backgroundPrompt: z.string().describe('A midjourney prompt for the game background image '), | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const throttleMap = new Map<Function, {throttledFunction: Function; args: any[]}>(); | |
/** | |
* Lets you call a function and have it throttled by a certain delay. | |
* Useful for when a function may be spammed! | |
* | |
* @example | |
* ``` | |
* function resize(w, h){ | |
* console.log('resized', w, h); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Global : | |
- Only optimize when you need to! Pixi can handle a fair amount of content off the bat. | |
- Be mindful of the complexity of your scene. The more objects you add the slower things will end up. | |
- Order can help, for example sprite / graphic / sprite / graphic is slower than sprite / sprite / graphic / graphic | |
- Some older mobile devices run things a little slower. passing in the option 'legacy:true' to the renderer can help with performance | |
- Culling, is disabled by default as its often better to do this at an application level. If you are GPU it will improve performance, if you are CPU bound - it will degrade performance | |
Sprites: | |
- Use spritesheets where possible to minimize total textures | |
- Sprites can be batched with up to 16 different textures (dependent on hardware) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var ResourceLoader = require('resource-loader'), | |
textureParser = require('./textureParser'), | |
spritesheetParser = require('./spritesheetParser'), | |
spineAtlasParser = require('./spineAtlasParser'), | |
bitmapFontParser = require('./bitmapFontParser') | |
// loader = new Loader(); | |
var Loader = function() | |
{ | |
ResourceLoader.call(this); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FilterManager.prototype.calculateMagixMatrix = function (filterArea, wt) | |
{ | |
var m = new math.Matrix(); | |
// scale.. | |
var ratio = this.textureSize.height / this.textureSize.width; | |
m.translate(filterArea.x / (this.textureSize.width), filterArea.y / this.textureSize.height); | |
m.scale(1 , ratio); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* User: xperiments | |
* Date: 14/03/13 | |
*/ | |
declare module PIXI | |
{ |