• Content Count

  • Joined

  • Last visited

About Telinc1

  • Rank
  • Birthday January 24

Contact Methods

  • Website URL
  • Twitter

Profile Information

  • Gender
  • Location

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Telinc1

    I'm trying to learn phaser 3

    Making a variable wouldn't do anything by itself. It would be useful only if you need to reference the image later. It's likely that the problem here was not using a web server. Because of the security rules of browsers, you cannot load local files from within a web page, even one which is also a local file. You need to have a web server running locally so you can load files normally.
  2. Telinc1

    How do I update console.log?

    console.log just outputs a static message to the console. You can't update it from your game code. The lazy solution for this would be to log the body every frame (in the update method). That'd work but it'd clutter the console really quickly and is probably not what you want. The Chrome developer tools support a feature called live expressions - it's the eye icon right above the console. If you can get to your player from the window's scope, you can make a live expression which updates it for you. The easiest way would be to temporarily store the player as a global variable from your code. Alternatively, you can store your game and use the Scene Manager to get your Scene, from which you'll be able to get your player.
  3. Telinc1

    Phaser 3 : Draw Circle style timer

    This example on Phaser 3 Labs could help. You can draw a stroked circle and a thicker arc inside a Graphics object to reproduce that timer. You'd need to clear the Graphics object every frame and redraw the arc based on how close your timer is to completion. Keep in mind the angles are in radians. 0 radians is the rightmost (east) side. You'd need to start at -90 degrees and go up to 270 degrees clockwise - the end angle will, of course, be a function of the elapsed time. The text in the center of the timer can just be a normal Text object.
  4. Telinc1

    Animation on follower object?

    As samme already said, a Path Follower is a subclass of a Sprite. This means that it has all of the properties of a Sprite, so you can animate it like you would animate any other Sprite. There are plenty of examples of animation, just substitute the Sprites in them with your Path Follower.
  5. Telinc1

    Tilemap objects

    Object layers simply hold geometric data which Phaser rarely uses directly. It's up to you how you treat that data - if you loop through the object layer, you can choose how to interpret each shape and whether you want to use its size at all. Unless you're setting a Sprite's size to the size of the tilemap object, it doesn't really matter how big it is. Anyhow, you can definitely resize objects in Tiled. Click on the object and you should get control points around it which you can use to resize it. Alternatively, you can directly enter a size in the object's properties. To answer your other question, moving the enemies wouldn't be a problem at all. Use the object data from the tilemap to add them as Sprites and you will be able to move them like any other Sprite.
  6. Telinc1

    Scratching Effect(mask)

    Keep in mind that Graphics objects are redrawn every frame. You don't see it directly but rendering a masked object requires rendering its mask, too. The code snippet you've posted doesn't make it immediately obvious how often you add new circles, but it's probably quite often if you're doing in an input event handler. This is likely the cause for the lag since you'll quickly reach hundreds of circles. The solution prob proposed uses a Render Texture instead of a Graphics object. Render Textures aren't cleared unless you do it yourself, so it should be quite a bit more efficient. The code in that post uses a Bitmap Mask, which is only available on WebGL, but you might still be able to use a normal Geometry Mask. I can't check the code for you right now, but I can't recall anything which would require a Graphics object.
  7. Telinc1

    static panels on top of rpg/tilemap game

    When you're more comfortable with Phaser, you can also consider moving your panels to a separate Scene. That would allow you to keep the UI's display list and logic separate from your gameplay, which may end up being easier to work with. For now, however, I'd go with Olf's solution of using `setScrollFactor`.
  8. Telinc1

    Multiple errors when using game.destroy(true)

    The first error is caused by Phaser trying to destroy the Data Manager of an Arcade Sprite. Do you ever touch the `data` property on any of your Arcade Sprites? If yes, consider switching to the `getData` and `setData` methods on the Game Object instead. Phaser expects the `data` property to be a Data Manager, so setting it to anything else without special precautions will result in an error like yours. I can't immediately pinpoint the cause of the second error. For some reason, the Event Emitter of a Scene's Systems object doesn't exist and I'm pretty sure that shouldn't ever happen (any external references to the Event Emitter would be cleaned up by whichever plugin uses them, so there's no need to destroy it when destroying a Scene). The Systems object is rarely touched, so I doubt you've ended up doing something to it from your code, but I can't think of any other possibility.
  9. Telinc1

    Rotate bounding box of follower object

    Based on the `` in the code, it looks like you're using Arcade Physics. If that's the case, keep in mind that Arcade Physics only support collision between axis-aligned bounding boxes (AABBs) and circles, i.e. you can't rotate bodies. If you need rotation, look into a more complicated physics engine such as Matter.js (it's available out-of-the-box). Phaser also supports Impact Physics, but I've never used them and I don't know if they support rotation. You could also combine a library like SAT.js with Arcade's collision handlers to pull this off, but it's likely a lot more complicated than switching physics engines, especially if you're early in development.
  10. Telinc1

    Phaser Canvas Destroy

    You can remove the entire game and everything in it by calling the `destroy` method on the game instance. If you want to remove the canvas element itself from the DOM, you can get a reference to it with the `canvas` property on the game instance, though I'm not sure if anything will break if you mess with it. If you haven't stored your game instance in a global variable (which is not the best practice, by the way), you can get it from the `game` on a Scene or its Systems object.
  11. Telinc1

    How to return a Phaser.Game object?

    What does your `makeGame` method do? If it just instantiates a `Phaser.Game`, you should be able to return it normally, at which point it'll be set as the `empire` variable. Note that, even if you return your game instance from `makeGame`, it won't be returned from the `loadData` method because an XMLHttpRequest is asynchronous and calls your `onreadystatechange` handler only after it completes. If you want your game instance in the `init` function, you should pass a callback to the `loadData` function and call it with the game from the `onreadystatechange` handler. Alternatively, you could research Promises.
  12. Telinc1

    How to refresh Matter world after Tilemap update?

    Judging solely from the source code, convertTilemapLayer creates a MatterTileBody for each colliding tile in the layer. The MatterTileBody constructor destroys the tile's existing body, so you could theoretically just call convertTilemapLayer again to recreate all of the layer's physics bodies. I can immediately see two possible problems with this, however. For one, convertTilemapLayer only processes colliding tiles, so it won't remove the body from a colliding tile which became non-colliding. In that case, you'd need to get the tile and manually call `tile.physics.matterBody.destroy()`... or you could just do that for the whole layer before calling convertTilemapLayer. Another problem I see is that you could end up needlessly recreating a lot of tile bodies, so I'd suggest looking at the source code of convertTilemapLayer (line 537 as of 4c4421c) and the related convertTiles (line 559 as of the same commit) method in the Matter World to update only a small region of tiles (in essence, you'd need to make a clone of convertTilemapLayer but with a changed call to getTilesWithin). I don't use Matter physics in my projects so I've got no idea if this is the best way to do this or if it'll even work, but it doesn't hurt to try if no one else has suggestions.