XekeDeath

Members
  • Content count

    316
  • Joined

  • Last visited

  • Days Won

    3

XekeDeath last won the day on December 27 2014

XekeDeath had the most liked content!

About XekeDeath

  • Rank
    Advanced Member
  • Birthday

Profile Information

  • Gender
    Male
  • Location
    Australia

Recent Profile Visitors

662 profile views
  1. When you are creating your baddies, you are assigning them all to the same variable... This is overwriting which baddie it is pointing to, so when you get to your Direction function, the variable is pointing at the last one you created... I see you are creating them with the baddies group... You can look into the forEach functions that a group has to loop over the baddies and call Direction on each of them...
  2. Generally, the X/Y of the object is used for calculations... Looking at the source code for this function, it is the X/Y of the object... Changing the anchor doesn't matter to the calculation at all... https://github.com/photonstorm/phaser/blob/v2.6.2/src/physics/arcade/World.js#L1918 You can also use game.math.distance to get the distance between two points... It takes the individual coordinates instead of the whole object as arguments... http://phaser.io/docs/2.6.2/Phaser.Math.html#distance How do you mean "distance between a point and a whole sprite"..? Do you want a collection of distances for each pixel the sprite is taking up, or just the X/Y...?
  3. If all you want is rendering, look at Pixi.js... Phaser 2 is a game engine, built with classes and ideas suited for building a game, and it is built on top of Pixi.js. Phaser 3 will not be using Pixi, but its own from scratch rendering engine... If you want to stick with Phaser, it already has the ability to customise your build, removing the elements you don't want... https://phaser.io/tutorials/creating-custom-phaser-builds
  4. When you are creating a slime, you are assigning it to this.slime... When you collide with ANY slime, this.slime is the one you are killing... It might be the right one, it might not be... (slime.body.touching.up){ this.player.body.velocity.y = -300; this.slime.play('slimeDead'); // THIS LINE HERE... this.game.time.events.add(Phaser.Timer.SECOND * 1, this.killEnemy, this); } Remove this. before slime, and see what happens...
  5. It is because you are creating new objects over the top of the previous ones, not reusing the same object. In create, assign your coinText to a single instance of the bitmapText, and in the update, change the coinText.text property.
  6. After a very quick glance, I would say change overlayer_group.addChild(layer); to overlayer_group.add(layer);
  7. // Enable input on the button... this.rePlay.inputEnabled = true; // Attach a function to the input down ( click/tap) this.rePlay.events.onInputDown.add(function() { this.game.state.start('name of the current state'); }, this);
  8. You are adding new callbacks each time squirrelThrowNut is called, and the old ones are still there... addOnce, as drhayes suggests will fix this for you, as the callback is removed when it is called.
  9. You'll want these things: Image/Sprite for the buttons... Image/Sprite input enabled to make the button clickable... Image/Sprite.events to find the interaction you want, and what the callback will receive... Phaser.Text for the text to tell them if they are right or wrong. For the answers part, you will need something to track your questions and assign an answer to each button... When the button is pressed, check the answer that you assigned it in the callback to see if they are correct, and adjust the text accordingly... Without writing it for you, that should be enough to get you going... The docs are very helpful...
  10. Try putting a breakpoint in the stop moving function and see what 'this' actually is... I have a suspicion that it won't be the ball object that you think it is, but the playstate object instead... The last argument sent to the overlap function is the callback context, meaning the object that "this" points to inside the callback function... There are several things you can do here: - Change the callback context to be the ball you are testing against. - Move the callback function to the playstate object, and use this.ball.body.velocity instead. Or, the one I would recommend, - Change the callback function to one on the playstate object, and make use of the parameters sent to the callback function... From the docs: update: function() { game.physics.arcade.overlap(this.ball, this.player2, this.collisionCallback, null, this); }, playstate = { // Your code collisionCallback: function(ball, player) { ball.stopMoving(); } }
  11. This is because you are creating new texts every time... They are not replacing the old ones, they are brand new objects, added to the stage on top of the old objects... You want to use this.game.add.text once, save the reference, then set the text value each time you want it to change... create:function() { // Your code this.gameMessage = this.game.add.text(this.game.world.width*0,this.game.world.height*0.75,"input text",this.style); } validateInput:function() { if(this.input.value=='') { this.gameMessage.text = "input text"; } else { if (this.input.value !== this.currRid.answer) { this.gameMessage.text = "you are wrong"; this.ridFactory(); } else { this.gameMessage.text = "you are correct"; } this.ridFactory(); } }
  12. I made exactly this sort of thing, with the typewriter effect and all, in the game I am currently making... Take a look here: http://xekeland.com/games/Rentahero Click play or tutorial when the menu loads, and you will see what I made for this sort of thing... The code is here: http://xekeland.com/my_games/Rentahero/states/Story.js There is some extra character movement stuff in there you may not want, and portrait display and positioning, but the text part is there... It uses a list of commands that it cycles through when the player clicks the screen... When it runs out, the scene changes to the next gameplay screen... edit: Forgot to mention that I also have a base scene set up to do fade transitions between scenes, using this.done to tell when I need to fade out... If you were having trouble finding where I swap scenes, it happens in a different file, but doFadeOut is used in this one to tell when I need it...
  13. Look into Bitmap Data... http://phaser.io/docs/2.6.2/Phaser.BitmapData.html Basically, create one of these, and use it as a texture for a sprite... You paint your splats onto the bitmap data, and they appear on the sprite...
  14. You have no draw calls between making it visible and hiding it again... You show the battleGroup, then you sit there and process the battle, then you hide it, then exit the function and continue regular program processing... All in one update call... You need to make it visible, then run several loops of the program to process the battle scene, then hide it once the battle is over... You will need to rethink using the while loop in there...
  15. http://phaser.io/docs/2.6.1/Phaser.Group.html#getFirstDead lazers is a Phaser.Group. getFirstDead will get the first child of the group that is considered dead... ie: The .alive property is false... Adding the extra parameters will create a new child sprite if it cannot find a dead one...