in mono

  • Content count

  • Joined

  • Last visited

About in mono

  • Rank
    Advanced Member
  • Birthday 09/11/1991

Profile Information

  • Gender
    Not Telling

Recent Profile Visitors

813 profile views
  1. Problem with world.scale.set() and angleToPointer()

    Yes, exactly. Any .set() you do on a Phaser.Point with only one argument, it applies that argument to both x and y. It's unlikely that they'd be different, just thought I'd mention it. By the way, if you don't mind me asking, what's your aim with scaling the whole world? What are you trying to achieve?
  2. Problem with world.scale.set() and angleToPointer()

    Just played with it and apparently you have to also scale the input. As weird as it is, you don't need the same scale, but the reciprocal of it. game.input.scale.set(1 / 1.35); P.S. Call this just after setting the world's scale. P.S.2 This assumes you have "square" scaling, i.e. scale.x === scale.y
  3. Maybe do it like this: class BaseGame extends Phaser.Game { constructor(width?: number | string, height?: number | string, renderer?: number, parent?: any) { super(width, height, renderer, parent); this.state.add("Main", MainState, true); } } class MainState extends Phaser.State { preload(): void { } create(): void { } update(): void { } doStuff(): void { } } window.onload = () => { let game = new BaseGame(400, 490, Phaser.AUTO, 'content'); } This way you won't have to hold a separate reference to the instance of Phaser.Game (BaseGame itself will be it). In the same line of thought MainState extends Phaser.State, so you don't have to explicitly define an object like you did. Of course, split this into files (each class in its own, plus the window.onload in a third one, maybe App.ts depending on your project structure).
  4. Preferred Language for Phaser?

    Started off with JavaScript a few years ago when ES6 was still a no-go. Moved to TypeScript a few months later and haven't looked back.
  5. load assets after preload

    You can try something like this: let imagesToLoad = ['image1.png', 'image2.png', 'image3.png'];;; ... but because (naturally) the images won't load immediately, you have to attach a callback and wait for the loading to complete like this:, this); and then do your stuff in a method called 'loadCompleted' in the same state. Haven't tested it, but it should work. Edit: maybe you should attach the callback twice (once before and once after) if you want to try adding stuff to the load queue right after preload(). If something is already loading, the error is probably because you're calling start() when the loader is still running.
  6. rotating sprite in direction of drag

    Collect a statistic of the last few points the car has been at and use them to smooth the rotation.
  7. Best Typescript/Phaser IDE?

    "The best" is a matter of preference as with everything else. For me, it's WebStorm. Maybe it had some issues with TypeScript in earlier days (two-three years ago), but it's mostly fine now.
  8. Collision mask in Phaser

    I haven't looked at the source, but I guess the two systems are pretty different in how they work, so I doubt you can just grab one feature from one of them and make it work with the other.
  9. Collision mask in Phaser

    I don't think it's about that. I think it's basically about telling "this group should collide with this group, but not with the other one". From what I know, it's available in p2, but not in arcade. I might be wrong, of course.
  10. How to save data for games deployed to steam

    Whatever wrapper you use to make a native app, it will still be using a browser internally, so yes, localStorage is a valid option.
  11. Retain score after state change

    The sane way to do this would be to use a server to verify the score, because anything you do on the client would be susceptible to tampering (if this is a concern). You can use localStorage as long as the game is on the same domain.
  12. Help with scales?

    Scaling a sprite means affecting its original pixel dimensions. When you initially create a sprite, it will appear in the game in its initial dimensions, in your case 400*32, and it will have a scale of (1, 1). You can manually change the width and height of the sprite and the scale will update accordingly, e.g. setting width to 800 will make scale.x equal to 2 (and vice versa: setting scale.x to 2 will make the width 800). It's usually set uniformly (i.e. scale.x is equal to scale.y), otherwise the image will appear with non-square pixels. As for positioning, all sprites are initially created with anchor set to (0, 0), which means that all transforms (positioning, rotation, scale and so on) happen according to the top left corner of the sprite. If you set its position.y to, it will appear just outside of the visible part of the game, that's why you offset it by 64 in this case (its height after the scale).
  13. Use the debugger statement. Wherever you want a breakpoint, just put debugger; immediately before. This will work in Chrome and other Blink-based browsers (and also in Firefox I believe) as long as you have a dev tools open. If you want to temporarily disable it, right click on the line number where "debugger" appears and choose "Never pause here".
  14. wich word "this" replace in this line ?

    The "this" in the first example refers to the current Phaser.State. The fact that you can call the same way that you can call this.add is dictated by the fact that they both refer to the same thing (i.e. the state has a reference to an instance of Phaser.GameObjectFactory; the game has a reference to that very instance - and it's the same for a lot of other things).
  15. how to create slider bar like that?

    You'd need a bunch of sprites - one with fixed size for the background, one for the slider button (also fixed size) and one with fixed height and variable width that will stretch along with the slider button. For the implementation itself... I don't have the time to put something together, but you're probably looking to enable input and drag on the slider button, constrain it so it's only able to move along x; then override the sprite's update() method and disallow it to move past certain points (this can be tricky) and update the other sprite's scale.x (so that it stretches to the needed width).