Yeah I'm thinking that's what I might have to do, thanks!
Liam Brocklehurst
Recent community posts
I might be missing something here, but I'm just wanting to check if an asset exists (from a path) before I assign it to something.
For example, I would do something like:
this.mySprite.setSprite("Path/To/Sprite");
but I'd like to be able to do:
if(AssetExists("Path/To/Sprite") this.mySprite.setSprite("Path/To/Sprite");
You could give this a go? https://github.com/eonarheim/TypeState
Friend of mine is working on possibly implementing this system into our game currently.
I recently needed to get the screen position of a player for checks to move the camera, so I added some functions to allow me to do this - figured it might help someone else! If anyone spots any errors, let me know and I can update. I imagine this'll only work for 2D games!
Firstly, I created a class that could hold top, bottom, left, right bounds (reusable for a few things):
class Bounds { constructor(public top: number, public bottom: number, public left: number, public right: number) { } }
We can then use this within our CameraHelper class:
class CameraHelper { static WorldToScreenPoint(x: number, y: number, cameraName: string): Sup.Math.Vector2 { let cameraActor = Sup.getActor(cameraName); let cameraPos = cameraActor.getPosition(); let cameraBounds = CameraHelper.CameraBounds(cameraName); return new Sup.Math.Vector2( (x - cameraBounds.left) / Sup.Game.getScreenRatio().width, (y - cameraBounds.bottom) / Sup.Game.getScreenRatio().height ); } static CameraBounds(cameraName: string): Bounds { let cameraActor = Sup.getActor(cameraName); let cameraPos = cameraActor.getPosition(); return new Bounds ( cameraPos.y + (Sup.Game.getScreenRatio().height / 2), cameraPos.y - (Sup.Game.getScreenRatio().height / 2), cameraPos.x - (Sup.Game.getScreenRatio().width / 2), cameraPos.x + (Sup.Game.getScreenRatio().width / 2) ); } }
CameraBounds returns a Bounds type of the world position of the top, bottom, left and right of the camera. WorldToScreenPoint then takes these values and determines what screen point (0-1) the x,y parameters are at.
Sup.Game.getScreenRatio() is possibly not giving us accurate calculations, so if I find a better way (or if someone lets me know) I'll get that changed.
Hope this helps someone!
I was wondering if there's a good method for making the app go fullscreen and lock orientation? Looking into working with mobile, so these things would obviously be a big help. Unless I'm best wrapping the project within an app that'll sort this out for me?
Not entirely new to game making, but very new in working with web apps/games!
Yeah, no problem! Here's what it's giving me:
SupEngine.js:21795 THREE.WebGLRenderer: Error creating WebGL context.THREE.WebGLRenderer @ SupEngine.js:21795 index.js:18822 Uncaught TypeError: Cannot read property 'setClearColor' of undefined SupEngine.js:21620 THREE.WebGLRenderer 73 SupEngine.js:21795 THREE.WebGLRenderer: Error creating WebGL context.THREE.WebGLRenderer @ SupEngine.js:21795 index.js:18822 Uncaught TypeError: Cannot read property 'setClearColor' of undefined
I've launched Superpowers with no problems on my PC and friend has been fine working with it, but I'm currently having problems running it on my laptop? I'm having nothing show in the Viewports and I'm unable to add most things (Nodes, Scene Objects, Sprites) This is what I'm seeing in the right menu when on the Cubic Model screen:
Do you know what could be wrong? I feel like it might be some sort of dependency that I don't have installed, but I'm not sure what it could be?