misfit

Members
  • Content Count

    8
  • Joined

  • Last visited

About misfit

  • Rank
    Newbie

Recent Profile Visitors

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

  1. Hi, I hope I have titled this question correctly. I would like to know how to check that this.load.on has ' progress' or 'complete' or any other event that I can use if I need to ( or any other object in Phaser 3). Is there a way to check it? Thanks!
  2. misfit

    checkWorldBounds

    Hi, I had some trouble with checkworldbounds as well. I would suggest that you just create a new gameObject collider outside the camera bounds ( or group of them if you need to check all bounds) and check collision with it. Hope it will help. this.bottom_collider = new Phaser.Physics.Arcade.Sprite(this,0,this.cameras.main.height,).setOrigin(0, 0); //no idea if it is necessary this.bottom_collider.width = this.cameras.main.width; //add to scene this.add.existing(this.bottom_collider); //add to physics this.physics.add.existing(this.bottom_collider,true); //set the physics body width/height to accommodate your desired size this.bottom_collider.body.width = this.cameras.main.width; //after that just add overlap this.physics.add.overlap(elementToCheck, this.bottom_collider, callbackFunction,null);
  3. So i want to add listener to when the sprite goes out of bounds of the screen. It doesn't seem to fire up. Am I missing something? I saw a post here about this but it uses this.physics.world.on("worldbounds".. but isn't there a way to encapsulate the listener inside a new Sprite child class? Btw is there a list of events i can listen to? Thanks! class Meteor extends Phaser.Physics.Arcade.Sprite{ constructor(scene,x,y,key_texture,frame){ super(scene,x,y,key_texture,frame); this.scene = scene; this.scene.addToWorld(this); this.scene.physics.add.existing(this,false); this.setCollideWorldBounds(true); this.addListener("onOutOfBounds",()=>{console.log("hello")}); } } Ok so apparently if i am setting this.collideWorldBounds(true) it console.logs this.body.onWOrlBounds as true but console.log this has it set to false. If I add a new Meteor(..) from scene.create() method it works fine. If I add it from Spawner class it doesn't.
  4. Hi, I have been going through a tutorial on recreating FruitNinja (unimportant maybe). I am a beginner in JS with experiance in Java. I need some help or reference where to get it - I have 2 states like this: var FruitNinja = FruitNinja || {}; FruitNinja.JSONLevelState = function () { "use strict"; Phaser.State.call(this); }; FruitNinja.JSONLevelState.prototype = Object.create(Phaser.State.prototype); FruitNinja.JSONLevelState.prototype.constructor = FruitNinja.JSONLevelState; (...) FruitNinja.JSONLevelState.prototype.create = function () { this.create_prefab(prefab_name, this.level_data.prefabs[prefab_name]); }; FruitNinja.JSONLevelState.prototype.create_prefab = function (prefab_name, prefab_data) { if (this.prefab_classes.hasOwnProperty(prefab_data.type)) { do stuff... }; (...) and var FruitNinja = FruitNinja || {}; FruitNinja.LevelState = function () { "use strict"; FruitNinja.JSONLevelState.call(this); this.prefab_classes = { "background": FruitNinja.Prefab.prototype.constructor, (...) }; }; FruitNinja.LevelState.prototype = Object.create(FruitNinja.JSONLevelState.prototype); FruitNinja.LevelState.prototype.constructor = FruitNinja.LevelState; FruitNinja.LevelState.prototype.create = function () { "use strict"; FruitNinja.JSONLevelState.prototype.create.call(this); (...) } Somehow JSONLevelState can access LevelState this.prefab_classe object. I don't understand how. Can I somehow print it to chrome console? Or can someone explain it or point me to some external reference ? I have watched couple of videos on youtube on inheritance in JS but I still don't get it. Please help, Ok Solved. "FruitNinja.JSONLevelState.call(this);" allows dunc from JSONLevelState be called in LevelState object (having access to its variables. Watch https://youtu.be/PMfcsYzj-9M for a complete explanation.
  5. Hello, I have been using phaser 2.6.2 and this emitter worked fine: var emitter = this.game.add.emitter(hitMeteor.body.x+hitMeteor.body.width/2, hitMeteor.body.y+hitMeteor.body.height/2, 6); emitter.makeParticles('meteorPiece'); emitter.minParticleSpeed.setTo(hitMeteor.body.width/2,-hitMeteor.body.height/2); emitter.maxParticleSpeed.setTo(70,hitMeteor.body.height/2); emitter.gravity = 0; emitter.start(true,1000,null,100); Today I have copied a new version (phaser 2.7.3) and the particles just stay in place rotating like their speed was equal to 0. In the docs I did not find any of those functions deleted so I am not sure what is wrong here. Thanks for all the help! *** OK. Deleting emitter.gravity = 0; helped.
  6. Hello, I have recently started using Phaser too. If you are familiar with Udemy.com learning site there is a free Phaser video tutorial that covers all the basics. There are also many examples like https://phaser.io/examples/v2/sprites/out-of-bounds showing how to spawn/respawn enemies outside the screen and many more. There you can find basic solutions for many ideas for your game. Good luck!
  7. Hello, I want to move group of sprites toward the player: var goBack = this.game.add.tween(this.pullGroup); goBack.to({x: this.player.world.x,y: this.player.world.y},2000); goBack.start(); But it seems that the group treats coordinates x, y as starting from group (like it has its own coordinate system) and not from Canvas' (0,0). How to make the tween movement work with world coordinate system and not in group (0,0)? Thanks for help, Edit #1 Ok I have overcome this problem by dividing player.x - child[0].x and the same for y.
  8. Hi I have a similar problem. My game uses: buildEmitter: function(){ this.burst = this.add.emitter(0, 0, 80); this.burst.minParticleScale = 0.3; this.burst.maxParticleScale = 1.2; this.burst.minParticleSpeed.setTo(-30, 30); this.burst.maxParticleSpeed.setTo(30,-30); //this.burst.maxParticles = 80; this.burst.makeParticles('explosion',0,20,true,false); this.input.onDown.add(this.fireBurst, this); }, fireBurst: function(pointer){ //passing input this.burst.emitX = pointer.x; //do emitting in coords of the pointer (finger) this.burst.emitY = pointer.y; this.burst.start(true,2000,null,20); }, Earlier whit makerParticles('explosion'); constructor the game allowed to click 4 time each producing 20 particles. When added overlap(..) check I needed to modify emitter as follows: makerParticles('explosion',0,20,true,fale); constructor. Now I am only able to click 1 and produce 20 particles, other clicks are unresponsive until particles disappears. I would like to know how to set a limit of 80 particles on the screen and be able to click 4 times (produce 20 particles each time) until the limit is reached = clicking doesnt do anything until some particles vanish, and still be able to check overlap collisions. Please help, *** Ok I have found the solution. I have just started learning JS and Phaser so I did not know teher is 'undefined' variable type and using ('explosion',undefined,undefined,true,false); did the trick. Sorry for a useless post.