From df370080432c05e20c9d0a9f6bdc7566d2dd48c2 Mon Sep 17 00:00:00 2001 From: florisdh Date: Wed, 10 Jul 2019 23:42:17 +0200 Subject: [PATCH] Initial setup --- .gitignore | 4 + .npmignore | 4 + package-lock.json | 507 ++++++++++++++++++++++++++++++++++++++++++++ package.json | 30 +++ src/baseState.ts | 20 ++ src/iState.ts | 11 + src/index.ts | 3 + src/references.d.ts | 1 + src/stateManager.ts | 62 ++++++ tsconfig.json | 12 ++ 10 files changed, 654 insertions(+) create mode 100644 .gitignore create mode 100644 .npmignore create mode 100644 package-lock.json create mode 100644 package.json create mode 100644 src/baseState.ts create mode 100644 src/iState.ts create mode 100644 src/index.ts create mode 100644 src/references.d.ts create mode 100644 src/stateManager.ts create mode 100644 tsconfig.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..34c72d5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +node_modules +.tscache +build +*.tmp diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..d26522c --- /dev/null +++ b/.npmignore @@ -0,0 +1,4 @@ +src +node_modules +.gitignore +tsconfig.json diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..28d7817 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,507 @@ +{ + "name": "pixi-scenes", + "version": "0.0.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "@pixi/accessibility": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/accessibility/-/accessibility-5.0.4.tgz", + "integrity": "sha512-NghhbRMe184NuuItwLncYuetOcyrBT08HPN9X3uhz2QuW3KLCEA/NTJhJF+uyGAa6bMAnEB3O8cJnP7NJWvZ4w==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/app": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/app/-/app-5.0.4.tgz", + "integrity": "sha512-qAO/5TDJiEpZnXvvkj37mEACwJJ+1vfg5G4LMvIqyVcYoP7mapdHYNL0OdilqfjPShmcp1l5jZXIa6SSQedhKg==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4" + } + }, + "@pixi/constants": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/constants/-/constants-5.0.4.tgz", + "integrity": "sha512-M1w5ah3Ilp4hwW/jyX+v2b/nLhak35fA8yJk23BbgQKIhqng0s78cCLBTvoCV/s7cEVcm0kive+TEWs+YJl5Vg==", + "dev": true + }, + "@pixi/core": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/core/-/core-5.0.4.tgz", + "integrity": "sha512-P2K2JJC+BFZrRZT9P0+Ir8jd7VrH6w7/L1Njg2+iSetW9TdjkPahR+w93VGwpEzEkrYHoNs6FbSFCY38P/6g8A==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/runner": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/ticker": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/display": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/display/-/display-5.0.4.tgz", + "integrity": "sha512-SokeMauhg1v6W8NJQfdpKnAx28afbdL2eB/yKgfH9mOHol/A2Zwfx2ZpaXfAMA9jySEL16jpRNqWh/3kf6GPKw==", + "dev": true, + "requires": { + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/extract": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/extract/-/extract-5.0.4.tgz", + "integrity": "sha512-dnBPfQXvUss0HXQ81v9OlRj6tQX55wRtuKek5gqDn1do0n1j5uvi+frLTRLFfgIIK3T08wbbYb6bFFiiL4nQFw==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/filter-alpha": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-alpha/-/filter-alpha-5.0.4.tgz", + "integrity": "sha512-TcHukIRQzwl/U44j7ytV+dRJmyF8vgcRutRobFkQYUwL83sPBybFiITiQ+xIJddxtEVBIgIO9SA9Dss3zIylIA==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4" + } + }, + "@pixi/filter-blur": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-blur/-/filter-blur-5.0.4.tgz", + "integrity": "sha512-HHrOCOY4SiaEzWbiXl7mdjTxf+f762ms0+BcPq4MWdNG1voZDN0XPr9s5eL635zwyfONF9XHcsaiPzqwOARoeg==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/settings": "^5.0.4" + } + }, + "@pixi/filter-color-matrix": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-color-matrix/-/filter-color-matrix-5.0.4.tgz", + "integrity": "sha512-uNY32xd7dt6g+Pe+3QJBBwTAuNQKvAx1EYEvRT8rFlye/TAYeXkAbxWjLYBFpnlZLaCNHLfjOu6UZBhwaqlZ/w==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4" + } + }, + "@pixi/filter-displacement": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-displacement/-/filter-displacement-5.0.4.tgz", + "integrity": "sha512-XCDrIF84K5RcafUDO78GlgwZ99+0FC/VS50qhLlnM9PyxKLrDXOUim8VsOZL+bycrArK5VgwK5G/sBI69Eqe9Q==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/math": "^5.0.4" + } + }, + "@pixi/filter-fxaa": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-fxaa/-/filter-fxaa-5.0.4.tgz", + "integrity": "sha512-8NfOQ5jz9hYlvXaNrBuCJvACqXE4gt3IURoD13SK5fMdbtdJZsv9DS1bvb2gpQwS4EhDmw8gNimcy1UIzk72Fg==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4" + } + }, + "@pixi/filter-noise": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/filter-noise/-/filter-noise-5.0.4.tgz", + "integrity": "sha512-QpKN4JhgdG75zH8uxv2PWPux7vrjOEnTtpLe3p+f/C+QQb+OD4duzTFS6k4flAZMdEkloZk9MoJPLn6I/S00NQ==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4" + } + }, + "@pixi/graphics": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/graphics/-/graphics-5.0.4.tgz", + "integrity": "sha512-Q8ZQdkMRAsd9U85rP9M1y5PYrE+hNLDOUJ1yKdVdcpq0UzrDflvVKpk58bcSNXR4a+lpYz1Ly6Pi+Xv6Hb1R1A==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/interaction": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/interaction/-/interaction-5.0.4.tgz", + "integrity": "sha512-DRFqLfIWZq+2O+3+yLzQDY366ZYbcptoY1AUCsDbIKgN6lM9CZnw5MckXjXuhat8RnZ80mXXi7lBqD03Y9+RVQ==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/ticker": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/loaders": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/loaders/-/loaders-5.0.4.tgz", + "integrity": "sha512-SRboskl4eK5eBALGafUwkVSIFxqAmRZwISTOOPmEnn372+bdrp7FtKEzdF5aZoKv0ugsQ0/NjUEaqZD2Ux6z+Q==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/utils": "^5.0.4", + "resource-loader": "^2.2.4" + } + }, + "@pixi/math": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/math/-/math-5.0.4.tgz", + "integrity": "sha512-Guhhm5m+jZu4vKusb/c4iwS+DOGJc/ePIaSHwRxqzL9FZr7y4RmjzH0793k8KHtmUWITqh4ABdG89/u0mYlY5w==", + "dev": true + }, + "@pixi/mesh": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/mesh/-/mesh-5.0.4.tgz", + "integrity": "sha512-lITixOeeq2BNspg8C0gCIEiOC02bh5oxVz+0C0f4EDYYYnjjsJ3RGu1ifuUZfhh1FPGa2RTZSBRtljbqOMwNTg==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/mesh-extras": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/mesh-extras/-/mesh-extras-5.0.4.tgz", + "integrity": "sha512-twnXqvve4Emf04AQ1IuFK8vXMxQzQJ+K3Au7wShqtPTD21d3hweVe7HAl8Kh0q2JWg3UGQtRURamcvQDkNa4Bw==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/mesh": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/mixin-cache-as-bitmap": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-cache-as-bitmap/-/mixin-cache-as-bitmap-5.0.4.tgz", + "integrity": "sha512-HzE4gbZyX23DfJYdaaAbViD11lWzWoNO0fAFJLydgL3maoRyE3kCQGHbVxotz7fBSeC4NZmlE8ttTpADv8MTFA==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/mixin-get-child-by-name": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-get-child-by-name/-/mixin-get-child-by-name-5.0.4.tgz", + "integrity": "sha512-QxSZutUh4xPr9PZctkOdiWDfmmwDMzJegusOA4ZaNwZink/nEzgVyfE7s5icKoAXQOVOrak2ugl7PVt5IAAgqQ==", + "dev": true, + "requires": { + "@pixi/display": "^5.0.4" + } + }, + "@pixi/mixin-get-global-position": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/mixin-get-global-position/-/mixin-get-global-position-5.0.4.tgz", + "integrity": "sha512-KhrCjIU8Udk2avPjBpyGHDaDcGMsXqr1xphDc1eeZ4rSi/QXLznzW4TF3oKQKiOulSIYdpXQDp79RQA3YGVPbQ==", + "dev": true, + "requires": { + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4" + } + }, + "@pixi/particles": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/particles/-/particles-5.0.4.tgz", + "integrity": "sha512-W995zZ8NRMpbqVrRQhx/FBF2Ty5YMU8QxpwjKyxIhORDUB7HRxKbPQ3NhQ2ByeH0i93UZutA0cQFToItkX/3aw==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/polyfill": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/polyfill/-/polyfill-5.0.4.tgz", + "integrity": "sha512-NjHHeP1U4gxiWu5iVhRf5YWYsX2M8VaLkT3XsjuBDRdiR/AWzpvXIk3k7sYMsMhidgP5dBfzGzxSf3hACtpDXg==", + "dev": true, + "requires": { + "es6-promise-polyfill": "^1.2.0", + "object-assign": "^4.1.1" + } + }, + "@pixi/prepare": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/prepare/-/prepare-5.0.4.tgz", + "integrity": "sha512-KJgfXa5JF4s+Wt2siKKD51ntrLsmILx80Xmp3xIElBcu2LL4F1NVYfwUR+QUYwLUoIZPYQJmswh+oco8IhMpPg==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/graphics": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/text": "^5.0.4", + "@pixi/ticker": "^5.0.4" + } + }, + "@pixi/runner": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/runner/-/runner-5.0.4.tgz", + "integrity": "sha512-wrzzrwoLO9V3pQ9SyOaYYmHU63R6BuGVa8q6AI4A7B2+2L35fm6tVEv6Gkqasu8QUTW6Qi3fiNLsrJwfLFDb5g==", + "dev": true + }, + "@pixi/settings": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/settings/-/settings-5.0.4.tgz", + "integrity": "sha512-04CAGb93J+UJO5kXotB95NA2iTjwve7MZ+Ifs3KvYJN1iqJ9Aza64ygrzTtkmztKO+5qm3ODylVh4iTb9nGEJA==", + "dev": true, + "requires": { + "ismobilejs": "^0.5.1" + } + }, + "@pixi/sprite": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite/-/sprite-5.0.4.tgz", + "integrity": "sha512-IrLS0Mf51rIfOVbtkiilSiHe0x6XznIzxk/dt26BFfIubcCjZssf4pe3/nPrxot5MPjPUWf5uAtDY1NSWHMRlQ==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/sprite-animated": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite-animated/-/sprite-animated-5.0.4.tgz", + "integrity": "sha512-tRwoe6rL/ofs5+rVn291Dv3/l34lT4KwVi8LhcnxXo5dglFNdGdksZ5ilNHOUPW9nAN/D99LO5HsVf7kQkIvKQ==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/ticker": "^5.0.4" + } + }, + "@pixi/sprite-tiling": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/sprite-tiling/-/sprite-tiling-5.0.4.tgz", + "integrity": "sha512-bNa6UpsDgtFjDT5+wubgldKt+5JNamTFL4eBaBCtfWwtlejpb6jlGJoMY+fR90071uN6e4NakqKYtTlfj2VMpg==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/spritesheet": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/spritesheet/-/spritesheet-5.0.4.tgz", + "integrity": "sha512-vQBK73rLzzaws31DEJ0zGuNbvWuSy756mJcMare4MFdP1fdshx7dfDQzFWYdH5ffvYAwNPPUcCZdjuaGKAxHuA==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/loaders": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/text": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/text/-/text-5.0.4.tgz", + "integrity": "sha512-20DyyyGlix3Skw7leHGDfQW5JpQNwnpFOtXY9t0XXJKBU4/nJDJ+wF1X7a6VuLZNLNLubnomEWtNoYgzNEHvXQ==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/text-bitmap": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/text-bitmap/-/text-bitmap-5.0.4.tgz", + "integrity": "sha512-Cw+NaZzVt1MfEdT11bq0bEAv9j3y9h18U5c4vOyMT0GbNrVDHTvSHfAvsU73+EJO3WmmiusHsV5r2IaGQt5XiA==", + "dev": true, + "requires": { + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/loaders": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "@pixi/ticker": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/ticker/-/ticker-5.0.4.tgz", + "integrity": "sha512-K2NlLxni40jK2pdCa0ImpTBK/MzIxxQkx1sWQpOAm4dl4QJhbURIzLS9z2DgJ8L5kPWAGWtaZde5Z1doTV48bw==", + "dev": true, + "requires": { + "@pixi/settings": "^5.0.4" + } + }, + "@pixi/utils": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@pixi/utils/-/utils-5.0.4.tgz", + "integrity": "sha512-j6DiIo18gkMZC64RqvZME5Cun5nQBB3OxnuT5rrQeBU+pM6kOfz8Akr8GNcbCukmjM1k3FALHyCF/OfnZCTDzw==", + "dev": true, + "requires": { + "@pixi/constants": "^5.0.4", + "@pixi/settings": "^5.0.4", + "earcut": "^2.1.5", + "eventemitter3": "^3.1.0", + "url": "^0.11.0" + } + }, + "earcut": { + "version": "2.1.5", + "resolved": "https://registry.npmjs.org/earcut/-/earcut-2.1.5.tgz", + "integrity": "sha512-QFWC7ywTVLtvRAJTVp8ugsuuGQ5mVqNmJ1cRYeLrSHgP3nycr2RHTJob9OtM0v8ujuoKN0NY1a93J/omeTL1PA==", + "dev": true + }, + "es6-promise-polyfill": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/es6-promise-polyfill/-/es6-promise-polyfill-1.2.0.tgz", + "integrity": "sha1-84kl8jyz4+jObNqP93T867sJDN4=", + "dev": true + }, + "eventemitter3": { + "version": "3.1.2", + "resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-3.1.2.tgz", + "integrity": "sha512-tvtQIeLVHjDkJYnzf2dgVMxfuSGJeM/7UCG17TT4EumTfNtF+0nebF/4zWOIkCreAbtNqhGEboB6BWrwqNaw4Q==", + "dev": true + }, + "ismobilejs": { + "version": "0.5.2", + "resolved": "https://registry.npmjs.org/ismobilejs/-/ismobilejs-0.5.2.tgz", + "integrity": "sha512-ta9UdV60xVZk/ZafFtSFslQaE76SvNkcs1r73d2PVR21zVzx9xuYv9tNe4MxA1NN7WoeCc2RjGot3Bz1eHDx3Q==", + "dev": true + }, + "mini-signals": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/mini-signals/-/mini-signals-1.2.0.tgz", + "integrity": "sha1-RbCAE8X65RokqhqTXNMXye1yHXQ=", + "dev": true + }, + "object-assign": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", + "integrity": "sha1-IQmtx5ZYh8/AXLvUQsrIv7s2CGM=", + "dev": true + }, + "parse-uri": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/parse-uri/-/parse-uri-1.0.0.tgz", + "integrity": "sha1-KHLcwi8aeXrN4Vg9igrClVLdrCA=", + "dev": true + }, + "pixi.js": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/pixi.js/-/pixi.js-5.0.4.tgz", + "integrity": "sha512-uQcY2AhJ2b8UZRgQzVKWC/P1Amk4cGUlXcb+65RBfRvHD6gJUkQJQAOPnaxb4+6VditSoDW7mI6uZAROuRiLoA==", + "dev": true, + "requires": { + "@pixi/accessibility": "^5.0.4", + "@pixi/app": "^5.0.4", + "@pixi/constants": "^5.0.4", + "@pixi/core": "^5.0.4", + "@pixi/display": "^5.0.4", + "@pixi/extract": "^5.0.4", + "@pixi/filter-alpha": "^5.0.4", + "@pixi/filter-blur": "^5.0.4", + "@pixi/filter-color-matrix": "^5.0.4", + "@pixi/filter-displacement": "^5.0.4", + "@pixi/filter-fxaa": "^5.0.4", + "@pixi/filter-noise": "^5.0.4", + "@pixi/graphics": "^5.0.4", + "@pixi/interaction": "^5.0.4", + "@pixi/loaders": "^5.0.4", + "@pixi/math": "^5.0.4", + "@pixi/mesh": "^5.0.4", + "@pixi/mesh-extras": "^5.0.4", + "@pixi/mixin-cache-as-bitmap": "^5.0.4", + "@pixi/mixin-get-child-by-name": "^5.0.4", + "@pixi/mixin-get-global-position": "^5.0.4", + "@pixi/particles": "^5.0.4", + "@pixi/polyfill": "^5.0.4", + "@pixi/prepare": "^5.0.4", + "@pixi/runner": "^5.0.4", + "@pixi/settings": "^5.0.4", + "@pixi/sprite": "^5.0.4", + "@pixi/sprite-animated": "^5.0.4", + "@pixi/sprite-tiling": "^5.0.4", + "@pixi/spritesheet": "^5.0.4", + "@pixi/text": "^5.0.4", + "@pixi/text-bitmap": "^5.0.4", + "@pixi/ticker": "^5.0.4", + "@pixi/utils": "^5.0.4" + } + }, + "punycode": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-1.3.2.tgz", + "integrity": "sha1-llOgNvt8HuQjQvIyXM7v6jkmxI0=", + "dev": true + }, + "querystring": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz", + "integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA=", + "dev": true + }, + "resource-loader": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/resource-loader/-/resource-loader-2.2.4.tgz", + "integrity": "sha512-MrY0bEJN26us3h4bzJUSP0n4tFEb79lCpYBavtLjSezWCcXZMgxhSgvC9LxueuqpcxG+qPjhwFu5SQAcUNacdA==", + "dev": true, + "requires": { + "mini-signals": "^1.1.1", + "parse-uri": "^1.0.0" + } + }, + "typescript": { + "version": "3.5.3", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-3.5.3.tgz", + "integrity": "sha512-ACzBtm/PhXBDId6a6sDJfroT2pOWt/oOnk4/dElG5G33ZL776N3Y6/6bKZJBFpd+b05F3Ct9qDjMeJmRWtE2/g==", + "dev": true + }, + "url": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/url/-/url-0.11.0.tgz", + "integrity": "sha1-ODjpfPxgUh63PFJajlW/3Z4uKPE=", + "dev": true, + "requires": { + "punycode": "1.3.2", + "querystring": "0.2.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..d0d9df9 --- /dev/null +++ b/package.json @@ -0,0 +1,30 @@ +{ + "name": "pixi-scenes", + "version": "1.0.0", + "description": "Managing multiple scenes within your pixi application.", + "main": "build/index.js", + "scripts": { + "build": "tsc" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/florisdh/pixi-scenes.git" + }, + "keywords": [ + "pixi", + "pixi.js", + "scenes", + "states" + ], + "author": "Floris de Haan", + "license": "ISC", + "bugs": { + "url": "https://github.com/florisdh/pixi-scenes/issues" + }, + "homepage": "https://github.com/florisdh/pixi-scenes#readme", + "dependencies": {}, + "devDependencies": { + "pixi.js": "^5.0.4", + "typescript": "^3.5.3" + } +} diff --git a/src/baseState.ts b/src/baseState.ts new file mode 100644 index 0000000..73f375e --- /dev/null +++ b/src/baseState.ts @@ -0,0 +1,20 @@ +import * as PIXI from "pixi.js"; +import {IState} from "./iState"; +import {StateManager} from "./stateManager"; + +export class BaseState extends PIXI.Container implements IState { + + public app: PIXI.Application|null; + public states: StateManager|null; + + constructor() { + super(); + this.app = null; + this.states = null; + } + + public init(): void {} + public start(): void {} + public stop(): void {} + public update(delta: number): void {} +} diff --git a/src/iState.ts b/src/iState.ts new file mode 100644 index 0000000..a5d63ce --- /dev/null +++ b/src/iState.ts @@ -0,0 +1,11 @@ +import * as PIXI from "pixi.js"; +import {StateManager} from "./StateManager"; + +export interface IState extends PIXI.Container { + app: PIXI.Application|null; + states: StateManager|null; + init(): void; + start(): void; + stop(): void; + update(delta: number): void; +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..f8c7398 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,3 @@ +export {IState} from "./iState"; +export {BaseState} from "./baseState"; +export {StateManager} from "./stateManager"; diff --git a/src/references.d.ts b/src/references.d.ts new file mode 100644 index 0000000..a41a0d6 --- /dev/null +++ b/src/references.d.ts @@ -0,0 +1 @@ +/// diff --git a/src/stateManager.ts b/src/stateManager.ts new file mode 100644 index 0000000..ff97ba4 --- /dev/null +++ b/src/stateManager.ts @@ -0,0 +1,62 @@ +import * as PIXI from "pixi.js"; +import {IState} from "./iState"; + +export class StateManager { + + private app: PIXI.Application; + private states: {[name: string]: IState}; + private current: string|null; + + constructor(app: PIXI.Application) { + this.app = app; + this.states = {}; + this.current = null; + // Listen for animate update + app.ticker.add(this.update.bind(this)); + } + + private update(delta: number): void { + let active: IState|null = this.active; + if (active) { + active.update(delta); + } + } + + public add(name: string, state: IState): void { + if (this.contains(name)) { + return; + } + this.states[name] = state; + //state.app = this.app; + //state.states = this; + state.init(); + } + + public contains(name: string): boolean { + return !!this.states[name]; + } + + public start(name: string): void { + if (!this.contains(name) || name === this.current) { + return; + } + + // Stop current + let active: IState|null = this.active; + if (active) { + active.stop(); + this.app.stage.removeChild(active); + } + + // Start new + this.current = name; + if (active = this.active) { + this.app.stage.addChild(active); + active.start(); + } + } + + public get active(): IState|null { + return this.current ? this.states[this.current] : null; + } +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..adc6359 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,12 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "amd", + "declaration": true, + "outFile": "build/index.js", + "strict": true + }, + "include": [ + "src/**/*" + ] +}