Jump to content

onlycape

Members
  • Content Count

    82
  • Joined

  • Last visited

About onlycape

  • Rank
    Advanced Member

Recent Profile Visitors

1413 profile views
  1. Hi @Pau, Now it works, but is very strange for me . I don't know why, but with your code, the params of "entra1" and "entra2" are in other order (the car is the second parameter, not the first, thats the reason of the errors).The "if" of entraArea2 is the location to execute the crossing action. Here the tested code in https://labs.phaser.io/edit.html?src=src\physics\arcade\overlap zone.js : var config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', physics: { default: 'arcade', arcade: { debug: true,
  2. Hi again @Pau, I think you can use something like this (I'm sure you can improve this code 😁 , I usually use Phaser CE) : var config = { type: Phaser.AUTO, width: 800, height: 600, parent: 'phaser-example', physics: { default: 'arcade', arcade: { debug: true, gravity: { y: 200 } } }, scene: { preload: preload, create: create, update: update } }; var zone1; var zone2; var group; new Phaser.Game(config); function preload () { this.load.image('space', 'assets/skies/space.jpg');
  3. Hi Pau, This is a way to do that (tested on phaser 3 sandbox): var overlapCollider; var overlapTriggered = false; /* ...... */ function create(){ /* ..... */ overlapCollider = this.physics.add.overlap(players, overlappingArea, goal.bind(this)); }; function goal(){ if(overlapTriggered){ this.physics.world.removeCollider(overlapCollider); return; }; console.log('overlap'); overlapTriggered=true; }; Without using the variable overlapTriggered, goal() would be executed 2 times. Regards.
  4. Hi @espace, I think that directly is not possible. But you can make your own wrapper function for "game.add.tween". Here a simple wrapper ( http://phaser.io/sandbox/BFoPWrWT ) : // Function to wrap game.add.tween function tweenWrapper(obj){ game.add.tween(obj.target).to(obj.properties,obj.duration,obj.ease,obj.autoStart,obj.delay,obj.repeat,obj.yoyo); } function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var config={ target: sprite, properties : { y:150, x:100, }, duration : 1000, ease : Phaser.Lin
  5. Hi @espace, When the object collide "in the air" : var timeStamp1 = performance.now() When the object collides with ground : var timeStamp2 = performance.now() The time the object take to fall to the ground in miliseconds is ----> parseInt ( timeStamp2 - timeStamp1 ) Regards.
  6. @BdR , No. If you load sound assets in a state with the option "autodecode" (example: this.game.load.audio('blaster', 'audio/SoundEffects/blaster.mp3', true)), then the decoded sounds will be stored in cache and available for other states. You can use a state to load the common assets only one time (like in the typical loading screen with progress bar). Regards.
  7. Hi @BdR, That DOMException is resolved with this (mygame.MyGameState was undefined): mygame.MyGameState = function(game){}; mygame.MyGameState.prototype = { preload: function() { ............... more code ............... Phase Sandbox can use the StateManager. Here a simple example: http://phaser.io/sandbox/UUWjHaIA Each state must contain at least a one of the required functions: preload, create, update or render (check your "mygame.MyState ") To change the game size use the size selector in the "Play" tab. Declaring a new Phaser.game adds other canvas, and seems g
  8. Hi @Phaser911, Instead of using 2 sprites for the background, you could use a single tilesprite and its autoscroll method ( https://photonstorm.github.io/phaser-ce/Phaser.TileSprite.html#autoScroll ). // in create function bgSpeed = 6; background = game.add.tileSprite(0,0,screenWidth,screenHeight,'imageKey'); background.autoScroll(bgSpeed,0); // bgSpeed in pixels per second // in buttonClick() function buttonClick() { bgSpeed = 9; background.autoScroll(bgSpeed,0); } Regards.
  9. Hi again @espace, The onComplete property of the Tween class is an object of the Signal class, which in this case calls its add method. This is the documentation of "Signal.add" method: https://photonstorm.github.io/phaser-ce/Phaser.Signal.html#add I am using Phaser CE, but in this case it does not change with respect to your version. Yes, is an optional argument. This code still works changing "this" with "null". Regards.
  10. Hi @espace, I think you probably have not passed the argument to the callback. Look at this code made in Phaser Sandbox (try the code here: http://phaser.io/sandbox/obVXEuZb/play ) : function create() { var sprite = game.add.sprite(0, 0, 'phaser'); var appears = function (obj,callback){ var tw = game.add.tween(obj).to( { x: 100 }, 2000, "Linear", true); // Here is the trick: add(callback, context, priority, args) tw.onComplete.add(callback,this,null,obj); }; var anim_obj = function(obj){ game.add.twe
  11. Hi @johann_dev, In first place, If you are using the renderer Phaser.WEBGL or AUTO then try changing it to Phaser.CANVAS. Some browsers have support for webgl but with very poor performance (especially on mobile). If you are using multiple text objects with webgl. Instead of system fonts it's much better for performance to use bitmap fonts (bitmapText object). Regards.
  12. Hi @zelcard, Nice game. I liked the game mechanics and the excellent visual effects. There are 3 points that I think could improve the game: Because the time of the game is limited, replay value is low. Some type of endless mode could improve this aspect. Some type of help / tutorial to know what to do at least in the first game. The music of the game could be coordinated with the different states of the game (for example, lower the volume at the beginning of the game, change to another music, ...). Here my best result 😁 : Regards.
  13. Hi @MackeyK24 , The latest Chrome update causes this problem. Now you need the first sound to be caused by the user (click, touch ...), only then you can play sounds without user intervention. In my case, I added a sound (with 0 volume) on the play button. And here other solution: http://www.html5gamedevs.com/topic/37384-no-sound-or-music-on-chrome-desktop-windows-10/ Regards.
  14. Hi @espace, There is a scope problem. You don't need to put the argument inside an anonymous function. The argument is already a function. This code works: var wait = function(callback,duration){ setTimeout(callback, duration); }; var f = function(){ console.log('executed'); }; wait(f,500); Regards.
  15. In this link they explain in detail the use of the "this" keyword in javascript: https://codeburst.io/javascript-the-keyword-this-for-beginners-fb5238d99f85 In my humble opinion (I'm a newbie in javascript and Phaser), your question is more related to javascript than to Phaser framework. Using more time in javascript learning at the end will save you a lot of time when developing in Phaser, and will provide you with other resources that in some cases the framework will not be able to offer. Regards.
×
×
  • Create New...