Popular Content

Showing content with the highest reputation on 07/20/2018 in all areas

  1. 1 point

    Drawing order of sprites

    There is second parameter in addTo function, which you can use to define the index where the sprite will be added in the array: sprite.addTo(container, 0); // Add to container at index 0 (which is first in the array) You can also swap positions of two sprites in the array: sprite1.swap(sprite2); // Swap positions of sprite1 and sprite2 in children array So there are lots of ways to change the drawing order.
  2. 1 point

    Drawing order of sprites

    How it is hard to use? Each container has children property, which is just a basic JavaScript array containing all objects (other containers, sprites, graphics etc) added to it. First object in the array will be renderer first, and so on. You can reorder that array in any way you want, even use your own sorting function. For example here i am sorting all objects added to a container every frame, based on their y position, so that lowest y is on top: game.createScene('Main', { init: function() { this.container = new game.Container(); this.contaienr.addTo(this.stage); // Add objects to the container }, sort: function(a, b) { return a.y > b.y ? 1 : -1; }, update: function() { this.container.children.sort(this.sort); } });
  3. 1 point

    mesh rotation do not change

    Hi @MinsuKim If the rotationQuaternion property is used, the rotation property will always be 0. if you want to use rotation, and not rotationQuaternion, something like: mesh.rotationQuaternion = null; should do the trick.
  4. 1 point

    Fonts and setFont()

    Good question. Font name and font filename are different things. You can have font named Arial in a filename font.fnt. You should be able to set the font name in the software that you use to generate the fonts. If you look inside the fnt file, the name should be defined as "face": When you load more than one font, you can set the font in a text using setFont function or as a parameter like this: // Create text using Arial font var text = new game.Text('Hello', { font: 'Arial' }); You can also set default font in your config. All texts that you create and do not define the font, will use the default font: game.config = { text: { defaultFont: 'Arial' } }; // If multiple fonts loaded, this will use the default font var text = new game.Text('Hello');
  5. 1 point
    Here is how I solve this. I adjust the predicted position of an opponent when it runs into a wall in the same way that I adjust your own players position without going through walls. I am doing collision checking for the opponent predicted positions as well for your own player (but only if in visible area). I always try to keep the predicted position within a certain range of the actual position. If an opponent's predicted position starts getting out of that range, I move it the minimum distance possible to get it back into that range, account for any collision. So the most choppy parts are when an opponent changes directions, but choppy movement is minimized by having this acceptable range of inaccuracy.
  6. 1 point

    mesh rotation do not change

    Only thing I can think of is that the mesh.rotation is not being used because there is a mesh.rotationQuaternion. https://doc.babylonjs.com/features/position,_rotation,_scaling#rotationquaternion What if you try something like this instead? mesh.rotate(BABYLON.Axis.Y, 0.1, BABYLON.Space.LOCAL);
  7. 1 point
    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?