Jump to content

NoxBrutalis

Members
  • Content Count

    50
  • Joined

  • Last visited

Reputation Activity

  1. Thanks
    NoxBrutalis got a reaction from LiadIdan in Error: No data found in the JSON tilemap from Tiled matching the tileset name: "gameTiles"   
    When you set tilesetImage(gametiles) you're using the key you gave the texture in game code. there should be an argument before that, and that's the name you gave the tileset image in tiled itself. 
    So, in my game, the key I gave the image was tiles, but in tiled for some reason I called it tilesheet. So I had to do this 
    this.tiles = this.map.addTilesetImage('tileSheet1', 'tiles'); if you called it gameTiles in tiled also, then:
    this.tiles = this.map.addTilesetImage('gameTiles', 'gameTiles');
  2. Like
    NoxBrutalis got a reaction from Pavel Mishin in SOLVED issue with world bounds collision   
    SOLVED AT LAST
    Im an idiot really as I think I read a post about this recently, but Im guessing a group is considered a container? I saw someone say that containers wipe set data from gameobjects when you add them to the container. This is definitely the case with group, though I'm wondering if this is expected behaviour? Im not sure as many people would spot it, as most people seem to have their players as standalone, but in my project the player is in a group with other friendly a.i sprites.

    So basically, if you add a sprite to a group after having set :

     
    this.player.setCollideWorldBounds(true); this.player.onWorldBounds = true; then its as if you never set it. So you either have to set them to true again, or set them to true after adding them to the group. There's possibly a way to set such properties on the group as a whole, but I don't know it.

    Anyways, so if your world bounds aren't working, check the order in which you initialise some of these properties  in relation to when you add the sprite to a group etc.
  3. Thanks
    NoxBrutalis got a reaction from dabe_glavins in Multiple scenes and animations, "Key already in use" when restarting a scene   
    Ive not done it myself, but I saw Rich say that  he has a dedicated 'preload' scene, where he puts things like animations. so put all the animations into the preload scene and then run that scene at boot and when you reset other scenes the animations wont get touched. 
     
    I found this, maybe it could be of help:

    https://gamedevacademy.org/creating-a-preloading-screen-in-phaser-3/?a=13
  4. Like
    NoxBrutalis got a reaction from Befive.Info in Sound accumulation when game not focused   
    Hey everyone, It seems that sounds are accumulating when  the game isn't focused. So when i click to another page for example, the sound of the game mutes, but when i click back to the game all the sounds that happened while it was muted seem to play all at once.

    Before this I think I was making it worse by not having sounds assigned to variables. So originally I was doing this whenever I needed a sound to play :

     
    this.scene.sound.play('sound');  
    the sound seems to be more consistent now that I also assign the sound to a variable and call play on the variable instead:

     
    this.sound_gunshot = this.scene.sound.add('gunshot') // gunshot already this.audio.load -ed this.sound_gunshot.play();  
    However, the problem still stands regarding sounds not being consumed when the game isn't focused. Any ideas about this?
    Thanks in advance for your time.
     
    EDIT - sorry I dont think this is actually an issue. Either it was just needing to change the way the sound was played, like above, or it was that I was using game.sound.add in one place instead of scene.sound.add. Either way I can't say that the problem is noticeable. Feel free to delete the post (don't think I can myself).
  5. Thanks
    NoxBrutalis got a reaction from reseto in preventing zoom on some objects   
    Yeah, if you're talking about your UI elements then, use a different scene is your best bet.
  6. Like
    NoxBrutalis got a reaction from kurhlaa in Different depth of one layer's tiles   
    Yes, you need to make a dynamic layer I believe. Dynamic layers, rather than static layers are for tile that you wish to modify during the game.

    here's a link to the docs on it:
     
    https://photonstorm.github.io/phaser3-docs/Phaser.Tilemaps.DynamicTilemapLayer.html
  7. Like
    NoxBrutalis got a reaction from greendot in Game Objects not being destroyed   
    you could also do:

     
    yourGroup.remove(object, true true); the remove has too bool params one to remove from scene, one to destroy. Glad you got it working
  8. Like
    NoxBrutalis reacted to rich in Not rotating from sprite origin   
    Origin(0,0) is the top-left, so the rotation looks right to me. You surely want 0.5, 0.5 so it rotates from the center?
  9. Like
    NoxBrutalis reacted to cseibert in Creating basic lighting system   
    Final update... I managed to get most of this working as desired.  Inside my update method I loop through all my player objects, and render the flashlight at the player's location:
     
    // somewhere inside update const context = this.lights.context; context.clearRect(0, 0, 1600, 1600); for (const player of state.serverState.players) { const positionX = player.x - this.player.x + 800; const positionY = player.y - this.player.y + 800; context.save(); context.translate( positionX, positionY, ); context.rotate(player.rotation); context.drawImage(window.flashlight, -800, -800); context.restore(); } this.lights.refresh();  

  10. Like
    NoxBrutalis got a reaction from mapacarta in preventing zoom on some objects   
    Yeah, if you're talking about your UI elements then, use a different scene is your best bet.
  11. Like
    NoxBrutalis got a reaction from Jackolantern in Phaser as Multiplayer Server   
    Indeed, your back end should be dealing in game abstractions rather than phaser data types etc. It would also be very bad for efficiency having those data types passed back and forth between the client, when simple numbers and strings could do. It's a lot like creating save game files and serializing data in that sense. When you save a game, you don't save all the objects and state and literally everything  - you save simple data types that act as signposts for rebuilding your types/objects/state etc. 
  12. Like
    NoxBrutalis reacted to rich in game variable unidentified inside create function   
    Or, if you prefer less typing:
    this.keyBools = this.input.keyboard.addKeys('W,S,A,D');
    There are lots of examples here too, for key events, key combos, etc: http://labs.phaser.io/index.html?dir=input/keyboard/&q=
  13. Like
    NoxBrutalis reacted to mm in Sounds keep looping after changing scene   
    That's a good solution, will also help with separating game and audio pause, thank you @NoxBrutalis.
    This gives me some more doubts about scene management:
    - When I change a scene, what parts of it keeps working? looks like audio keeps working, what about sprites? timers? script logic?
    - How can I clean/delete a scene on change?
     
     
  14. Like
    NoxBrutalis reacted to Jackolantern in Phaser as Multiplayer Server   
    This is not actually how you would create a multiplayer game. You would not run Phaser as-is on the server, since it is doing all kinds of things that you don't want done on the server, such as managing sprite images, drawing the screen, etc. It is crashing with a "window is not defined" error because Phaser is looking for the window object to do all of those things. You will also need to work with websockets, which is not something Phaser will do out-of-the-box.
    Rather, the general idea is that you use Phaser on the client-side to display the game and share as much of the code as possible through re-use in your server, but the server will be a distinct application that is different from the client. There will be times when the server needs to do things in somewhat of a different way than your client logic because the server has a much wider view of the game and it has to be more efficient. For starters, I would highly recommend reading Gabriel Gambetta's excellent series that outlines the basic concepts of making an authoritative server. It doesn't go over any code, but instead goes through the strategies to handle lag and other obstacles in multiplayer development. I would also recommend the Build New Games real-time multiplayer tutorial. That actually walks through some code for the user to see two different players moving around. As far as using Phaser 3 goes, you could check out the newer tutorial from Zenva. However, I would just consider that a starting point because there are some serious holes and missing parts from the code (such as client-side prediction, interpolation, etc.). I believe it would fall apart when real world latency enters the picture. But it does demonstrate pretty well how to get everything set up with Phaser 3 and could be a good starting point. Then there is also a good Phaser 2 tutorial and github found here.
    Hope this helps!
  15. Thanks
    NoxBrutalis got a reaction from Kimeiga in Animation oncomplete callback   
    In the example you quoted, the name of the animation is being concatenated to the end of a user defined event. It's Samme's way of making ti so he only get's events when it's a specific animation. I didn't know you could do that actually, hence the like
     
  16. Like
    NoxBrutalis got a reaction from Kimeiga in Animation oncomplete callback   
    this.on('animationcomplete', this.animComplete, this); in the above, you register the that you want the event to fire. In my example, this.animComplete is a function that will be called back to. Now, in that function, you have access to the current animation and the frame also, like so:

     
    animComplete(animation, frame) { if(animation.key === 'shoot') { this.animKeyStack.pop(); this.currentAnim = this.animKeyStack[this.animKeyStack.length - 1]; this.anims.play(this.currentAnim, true); } } Hope that helps, or makes sense. The point is the event has both the animation it is firing from as well as the frame if you need it. Just specify them as arguments to the function you call.
  17. Like
    NoxBrutalis reacted to cseibert in Custom Tile Collision Width   
    Thanks for the different approaches, I'll try to figure out which one is a best fit for my goals. This community is really helpful!
  18. Like
    NoxBrutalis reacted to peterhull90 in Bug in this.add.group(children) ?   
    Thanks NoxBrutalis, that use of createMultiple is not suitable for what I want but it's a really useful snippet.
    I will file an issue on github.
  19. Like
    NoxBrutalis got a reaction from peterhull90 in Bug in this.add.group(children) ?   
    so I played around with the createMultiple:

     
    create() { this.grp = this.add.group(); this.grp.createMultiple({ classType: Phaser.GameObjects.Sprite, key: 'health_bar', frame: 0, visible: true, active: true, repeat: 10, setXY: { x: Phaser.Math.RND.between(0, 500), y: Phaser.Math.RND.between(0, 500), stepX: 10, stepY: 10 } }); console.log(this.grp.children.entries.length); console.log(this.grp.children); this.grp.children.entries.forEach(ele =>{ console.log(ele); }); } part of this was because i finally found the part of the docs that lists all the config object properties(yay!), but also because this didnt make any sense. Well, if you use createMultiple, it does in fact populate the group unlike my earlier thoughts on it.
    So that's probably your best bet. 
    edit- realised you're not looking for a fix as such, you want to determine if it's a bug or not. I'll let better minds inform on this one.
  20. Like
    NoxBrutalis reacted to Tom Atom in Sprite is not rendered correctly (extra lines on the edge)   
    @pingu found the problem... it is related to Phaser texture creating. See method createTextureFromSource() (https://github.com/photonstorm/phaser/blob/master/src/renderer/webgl/WebGLRenderer.js#L1144)
    It sets wrap mode to CLAMP_TO_EDGE by default, which would be OK and no bleeding would be shown. But... if texture dimensions are power of two (which is your case), then it changes wrap mode to REPEAT. You can encounter imprecisions in GPU calculations, so your texture is drawn and small part is repeated - it is that bleeding. Your current sprite scale is 0.406, if you set it to 0.5, then calculations are little different and bleeding is not shown. If you animated scale, then bleeding would probably blink - sometimes shown, sometimes not.
    So, solutions are:
     - add extra padding around your shape as @bossikkk suggested. If you want to preserve texture size 512x512, then draw your shape 510x510 and leave 1px empty on all sides,
     - simply change dimensions of your texture to not be power of 2 - like add 1 empty line and column to make it 513x513 texture (this is OK for development, but I do not like this solution - not sure, but I have somewhere back in my mind, that some GPUs are adding extra space for non POT textures to force them to nearest POT - in your case it would be 1024x1024 with lot of memory eaten.)
     
  21. Like
    NoxBrutalis reacted to BdR in Phaser3 game example using scenes, a preloader and a loading bar   
    I've created a Phaser3 game template example, it's available on GitHub here:
    GitHub: https://github.com/BdR76/Phaser3-example-game
    Play demo: Phaser3 example game
    This is a Phaser v3 example game template, it's intended to show the structure of a typical Phaser3 game and using some of the key features of Phaser. It shows how to use separate scenes, a simple but effective loading bar, sprite atlas loading, sprite animation, buttons similar to Phaser v2 and more. It's a bare minimum game, a starting point of sorts. I hope it's useful for someone just starting out with Phaser development.
    Have fun with it let me know if you have any improvements.

    (Btw the only thing still missing is scaling or a scale manager, I'll add that at a later time)
  22. Like
    NoxBrutalis reacted to BdR in Create group with multiple sprites at random positions   
    Thanks @NoxBrutalis I was focusing to much on the .createMultiple() method. Simply creating the coins in a loop and then adding them to the group worked for me
    this.gameitems = this.physics.add.group(); for (var i = 0; i < 20; i++) { var x = Phaser.Math.RND.between(0, 800); var y = Phaser.Math.RND.between(0, 600); var newobj = this.gameitems.create(x, y, 'sprites', 'coin1'); } Btw is there a way to get the width and height values (800 and 600) from the current scene or game instead of using hardcoded numbers for the RND function?
  23. Like
    NoxBrutalis got a reaction from BdR in Create group with multiple sprites at random positions   
    If you console.log the group - console.log(coins.children.entries) What is the length/size of the group? It's possible that you're creating all the coins you need but they're all being put on the same spot. If that's the case then it's because your call to random only happens once when the create multiple function is called. I guess it's because the function isn't a loop and so only acts on the parameters you provide. 

    I'm not massively in the know about phaser, but you could try to circumvent this by simply creating coins in a loop and then adding them to the group. This way the random number will be new each iteration of the loop. 

    Hope that helps.
  24. Like
    NoxBrutalis reacted to Pau in Error: No data found in the JSON tilemap from Tiled matching the tileset name: "gameTiles"   
    Thank you! your explanation solved my problem.
    I share my on code-explanation.
    function preload(){ this.load.tilemapTiledJSON('level1', 'map.json'); this.load.image('tilesetNameInPhaser', 'tiles.png'); } function create(){ map = this.make.tilemap({key:'level1'}); tileset = map.addTilesetImage('tilesetNameInTiled', 'tilesetNameInPhaser'); backgroundLayer = map.createStaticLayer('background', tileset,0,0); } Thank you!
  25. Like
    NoxBrutalis reacted to samme in Create group with multiple sprites at random positions   
    See http://labs.phaser.io/edit.html?src=src/actions/random rectangle.js
×
×
  • Create New...