• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by codevinsky

  1. Part 4 is up:
  2. Part 4 is up: Timers, Group Recycling, & Death
  3. Wow. Thanks, Rich. Part 4 should be up by the end of the day.
  4. I have a group that has groups inside of it. This might be bad design and I'm willing to take a look at a different way of doing it. var MyGroup = function(game, parent) {, game, parent); this.add(spriteWithPhysicsBody); this.add(anotherSpriteWithPhysicsBody);}; MyGroup.prototype = Object.create(Phaser.Sprite);MyGroup.prototype.constructor = MyGroup; in my play state: create: function() { this.player = game.add.sprite(0,0, 'player'); this.groups =; this.groups.add(new MyGroup(,;},update: function() {, this.groups, this.collisionHandler, null, this);}This doesn't work. Nothing ever collides. But if I do this: this.groups.forEachExists(function(group) {, group, this.collisionHandler, null, this);}, this);Everything works. Am I making it too complicated, or is this the only way to do it?
  5. Ok... Let's do a bit of debug: Fireball.Game.prototype = { create: function () { this.physics.startSystem(Phaser.Physics.ARCADE); this.add.sprite(0, 0, 'background'); var map = this.add.tilemap('playfield', 32, 32); map.addTilesetImage('tiles'); map.setCollision(0); this.layer = map.createLayer(0); this.layer.resizeWorld(); this.layer.debug = true; this.player1 = this.add.sprite(200, 375, 'player', 0); this.player1.animations.add('jump', [0, 3]);'jump', 5, true); this.fireball = this.add.sprite(44, 70, 'fireball', 0, true); this.fireball.body.velocity.y = 60;; * 3, this.createFireball, this); }, update: function () { this.physics.arcade.collide(this.fireball, this.layer, this.killFireball, null, this); }, createFireball: function () { this.fireball =, 70, 'fireball', 0); this.fireball.body.velocity.y = 60; }, killFireball: function () { console.log('bang'); },We're going to turn on debug bodies for the tile map so that you can see where collisions are, and we're going to just create one fireball every 3 seconds. We're also just checking collision against that one fireball. What happens?
  6. So, tile[0] is the tile you want to check for collision against an item in your fireball group, correct?
  7. map.setCollision(0); Do you only have the one tile in your map?
  8. The correct line of code for testing collisions should be: this.physics.arcade.collide(this.fireball, this.layer, this.killFireball, null, this);
  9. I don't know how fast it is, but game.physics.arcade.distanceToObject will return the distance in pixels between two game objects. Looping through on screen enemies in a group and then running that calculation wouldn't be too bad.
  10. Yeah... it doesn't seem that we can actually change the display width. I've tried changing widths and setting the text's dirty property.
  11. codevinsky

    Line moving

    Ahh... You're using 1.1.5. change 'ctx' to 'context';
  12. Let me take a quick look...
  13. codevinsky

    Line moving

    I've copied your code to a codepen, replaced any reference to 'origine' with static variables, and added a sprite that uses the bitmapData (this.line) and it works just fine: // Initialize Phaservar game = new Phaser.Game(800, 600, Phaser.AUTO, 'game_div');// Creates a new 'main' state that will contain the gamevar main_state = { // Function called first to load all the assets preload: function() { // Load the sprite //'background', 'images/debug-grid-1920x1920.png'); },create: function() { //this.background =,0, 'background'); this.line = game.add.bitmapData(320, 480); this.sprite = game.add.sprite(0,0,this.line);},update: function() { this.line.clear(); this.line.ctx.beginPath(); this.line.ctx.moveTo(10, 10); this.line.ctx.lineTo(this.input.activePointer.x , this.input.activePointer.y); this.line.ctx.lineWidth = "5"; this.line.ctx.strokeStyle = 'white'; this.line.ctx.stroke(); this.line.ctx.closePath(); this.line.render(); this.line.refreshBuffer(); },}// Add and start the 'main' state to start the gamegame.state.add('main', main_state); game.state.start('main');
  14. codevinsky

    Line moving

    So, your code looks -exactly- like this? create: function(){ this.line = game.add.bitmapData(320, 480);},update: function(){ this.line.clear(); this.line.ctx.beginPath(); this.line.ctx.moveTo(origine.x, origine.y); this.line.ctx.lineTo(this.input.activePointer.x , this.input.activePointer.y); this.line.ctx.lineWidth = "5"; this.line.ctx.strokeStyle = origine.color; this.line.ctx.stroke(); this.line.ctx.closePath(); this.line.render(); this.line.refreshBuffer();}
  15. Can you show your code?
  16. codevinsky

    Line moving

    Can you show your code?
  17. I reached out to the creator of generator-phaser and we're going to collaborate on the generator. Thanks for the idea, Alvin
  18. I'll work on learning typescript this week, and then incorporating it into the generator.
  19. I may reach out to him, but we're using a different technology stack and have different workflows. For example: I'm using Grunt and Browserify. He's using Gulp. I've set up my workflow for dependency injection and inheritance. His is just... very flat. I've added subgenerators for states and prefabs, he's got nothing like that. I will send a message to him and see if he's interested in collaborating, though.
  20. codevinsky

    Line moving

    Here... try this:
  21. Without trying to bite anyone's style (specifically, lessmilk's), I've been writing a tutorial series for Phaser 2.0.x that uses the phaser-official generator to show how to build a perfect Flappy Bird clone from the ground up. Each lesson talks about core features of the Phaser Library that you'll need to know to build your own games. The Fully Playable Game: I'll update this thread each time a new part comes out: Part 1: Getting Started Topics Covered: Using the GeneratorStatesLoading AssetsSprites & AnchorsSimple SpriteSheet AnimationsSprite AnimationsTileSpritesGroupsTweensSimple ButtonsCallbacks and Callback ContextsBrowserify integrationPart 2: Intro to Physics and Prefabs Topics Covered: PrefabsIntro to Arcade PhysicsSprite Physics BodiesTileSprite Physics BodiesCollisionsPart 3: Intro to Player Movement Topics Covered: User InteractionKeyboardMouseTouchEnumsSignalsSprite RotationPart 4: Timers, Recycling & Death Topics Covered: TimersExtending GroupsRecyclingResetingDeath HandlingState ShutdownsPart 5: Sound, Scoring & Particles Topics Covered: ScoringHUD ManagementSoundParticlesPersistent StorageRestarting
  22. Part 3 of my Phaser 2.0 Tutorial: Flappy Bird series is up: Phaser 2.0 Tutorial: Flappy Bird (Part 3)
  23. I updated generator-phaser-official and the two tutorial posts to reflect these changes.