• Content Count

  • Joined

  • Last visited

Everything posted by ShadowMoon

  1. That just gives me: Uncaught TypeError: Cannot read property 'list' of undefined another undefined error, added the this keyword also/ this.container.list[0] and this.container.list.length same output
  2. So in my create function I make a container, populate it with a sprite 25 times in random positions and rotation. If I put console.log(container.length); I get 25. All good so far. But when I try to access it within an event I always get undefined. No matter how I try to call the container or it's children. I have tried 100 different ways. Including every combination of the this keyword. Little off topic, but I seem to really struggle with the this keyword and it's use in phaser. Constantly have problems accessing variables and such, with undefined errors. Is there a good tutorial for that? Is this more of javascript thing or phaser. Anyway this is the code after I create the container. It returns undefined, undefined this.input.on('pointerdown', function(container){ console.log(container[0]); console.log(container.length); for(var i = 0; i < container.length; i++){ console.log(i); container[i].setTint(Math.random() * 0xffffff); } }); Thank you.
  3. This doesn't work either for scaling and collision... ground.setDisplaySize(360, 140);
  4. Hmm, I have a ground image that I scaled up by 1.3. And I have it set to collide with a falling object. The falling object doesn't actually collide till it hits the unscaled edge of where the image would be, so basically the falling object goes half way through the ground then collides. I'm using phaser 3.3.0. How would I get the meteor to actually collide with the surface of the ground if I have to scale it? function preload(){ this.load.spritesheet('meteor', 'images/meteor.png', {frameWidth: 32, frameHeight: 32 }); this.load.image('ground', 'images/base.png'); } function create(){ meteor = this.physics.add.sprite(120, 120); meteor.body.allowGravity = true; ground = this.physics.add.staticImage(180, 584, 'ground'); ground.setScale(1.3,1.3); this.physics.add.collider(meteor, ground, crash, null, this); }
  5. Got it! Thanks everyone. I just made a variable moveLeft, set it to false. Then on the pressdown event changed it to true and have the if statement in update check the state. On tap, he hauls ass to the left Now the easy part of getting him moving left, right, and jumping. var moveLeft = false; function create(){ this.input.on('pointerdown', function(){ moveLeft = true; }, this); } function update(){ if (moveLeft) { player.setVelocityX(-160);'left', true); } }
  6. Hey samme, thanks! I was kind of looking at these. And this snippet will move the dude one little frame at a time: this.input.on('pointerdown', function(){ player.setVelocityX(-160);'left', true); }, this); but how can I get the update function to check if pointer is down, similar to what I'm able to do with the cursor keys? This is the example from the tutorial and it makes the dude run left. if (cursors.left.isDown) { player.setVelocityX(-160);'left', true); }
  7. Thanks for the video! He covers a lot on keystrokes and mouse input, but there still is nothing on mobile touch (taps / swipes). I am able to use hammer.js to detect swipes, but incorporating it into the update function is where I'm getting stumped for now. I'm pretty sure there is a way to handle touch events with just Phaser 3 which would be ideal.
  8. Are there any good examples or tutorials for swipes and touch/ tap events for Phaser 3. I am new to game development. I did this tutorial for phaser 3, played around with it, added sounds and such. But the next thing I wanted to do was try and port it to Android. I was able to get most of the look right, but for the life I me I can't figure out how to get the 'dude' to move!!! Any help would be appreciated. Thanks