# codevinsky

Members

212

5

1. ## Phaser 2.0 Tutorial Series: Flappy Bird

Part 4 is up: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-4/
2. ## List of Phaser Tutorials

Part 4 is up: http://codevinsky.ghost.io/phaser-2-0-tutorial-flappy-bird-part-4/ Timers, Group Recycling, & Death
3. ## Phaser 2.0 Tutorial Series: Flappy Bird

Wow. Thanks, Rich. Part 4 should be up by the end of the day.
4. ## [Arcade Physics] Colliding against a group of groups

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) { Phaser.Group.call(this, 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 = game.add.group(); this.groups.add(new MyGroup(this.game, this.group);},update: function() { this.game.physics.arcade.collide(this.player, this.groups, this.collisionHandler, null, this);}This doesn't work. Nothing ever collides. But if I do this: this.groups.forEachExists(function(group) { this.game.collide(this.player, group, this.collisionHandler, null, this);}, this);Everything works. Am I making it too complicated, or is this the only way to do it?
5. ## Arcarde Physics - Collision between Group and Tilemap

Huh. Interesting.
6. ## Arcarde Physics - Collision between Group and Tilemap

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]); this.player1.animations.play('jump', 5, true); this.fireball = this.add.sprite(44, 70, 'fireball', 0, true); this.fireball.body.velocity.y = 60; this.game.physics.arcade.enableBody(this.fireball); this.time.events.loop(Phaser.Timer.SECOND * 3, this.createFireball, this); }, update: function () { this.physics.arcade.collide(this.fireball, this.layer, this.killFireball, null, this); }, createFireball: function () { this.fireball = this.game.add.sprite(44, 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?
7. ## Arcarde Physics - Collision between Group and Tilemap

So, tile[0] is the tile you want to check for collision against an item in your fireball group, correct?
8. ## Arcarde Physics - Collision between Group and Tilemap

map.setCollision(0); Do you only have the one tile in your map?
9. ## Arcarde Physics - Collision between Group and Tilemap

The correct line of code for testing collisions should be: this.physics.arcade.collide(this.fireball, this.layer, this.killFireball, null, this);
10. ## Enemies IA that attack you if you are x pixels closer to them. [question]

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.
11. ## Phaser Text Width Issue

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.
12. ## Line moving

Ahh... You're using 1.1.5. change 'ctx' to 'context';
13. ## Phaser Text Width Issue

Let me take a quick look...

15. ## 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();}

19. ## Phaser 2.0 Tutorial Series: Flappy Bird

I reached out to the creator of generator-phaser and we're going to collaborate on the generator. Thanks for the idea, Alvin
20. ## generator-phaser-official: Yeoman Generator for Phaser projects

I'll work on learning typescript this week, and then incorporating it into the generator.
21. ## Phaser 2.0 Tutorial Series: Flappy Bird

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.
22. ## Line moving

Here... try this: http://codepen.io/codevinsky/pen/dAjDp/?editors=001
23. ## Phaser 2.0 Tutorial Series: Flappy Bird

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: http://flappy-bird-reborn.herokuapp.com/ 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
24. ## List of Phaser Tutorials

Part 3 of my Phaser 2.0 Tutorial: Flappy Bird series is up: Phaser 2.0 Tutorial: Flappy Bird (Part 3)
25. ## List of Phaser Tutorials

I updated generator-phaser-official and the two tutorial posts to reflect these changes.