• Content Count

  • Joined

  • Last visited

  • Days Won


Everything posted by XekeDeath

  1. You want this property on the images input handler: http://phaser.io/docs/2.6.2/Phaser.InputHandler.html#pixelPerfectClick Setting that to true will only register clicks that are over areas of the image that have an alpha value on and above the pixelPerfectAlpha threshold. http://phaser.io/docs/2.6.2/Phaser.InputHandler.html#pixelPerfectAlpha
  2. XekeDeath

    Issue with Text rendering

    Make sure the x and y values of the text are integer values... This aligns them to the pixel grid... If either value is not an integer value, it won't be properly aligned, and the rendering will be blurry as it tries to be half way across a pixel...
  3. XekeDeath

    Changing Origin Angle of Sprite from Left to Top

    Open the image in an editor and rotate it there...
  4. XekeDeath

    Issue with Text rendering

    The only time I have come across blurry fonts is when they have a off-pixel position... When you are redrawing the element, are you ensuring the text field it pixel aligned..?
  5. XekeDeath

    Problem with adding actions on a group of elements.

    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...
  6. 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...?
  7. XekeDeath

    Half way through my first Phaser Game, Need Advice

    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
  8. XekeDeath

    Wrong Sprite in Group being killed

    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...
  9. 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.
  10. XekeDeath

    Understanding how Phaser group works

    After a very quick glance, I would say change overlayer_group.addChild(layer); to overlayer_group.add(layer);
  11. XekeDeath

    simply click button to restart

    // 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);
  12. XekeDeath

    animation onComplete callback

    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.
  13. XekeDeath

    Phaser, replace text with user input?

    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...
  14. XekeDeath

    Sprite.Body is undefined

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

    Texts rendering over each other

    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(); } }
  16. XekeDeath

    Conversation in game

    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...
  17. XekeDeath

    Painting Shots

    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...
  18. XekeDeath

    set visible=true no use in Phaser

    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...
  19. XekeDeath

    function getFirstDead

    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...
  20. XekeDeath

    remove sprites onBeginContact in a loop

    Your problem is you are reusing the coin variable... By the time the callback is triggered, coin is pointing at the last coin only... You need a different way to reference the coin you want to remove in the callback... Without whipping up some test code, I can suggest: - putting var in front of coin to see if that helps... - storing the coins in an array, putting the index on the coin object, and using that to refer to the coin - See if this will help you: http://phaser.io/docs/2.5.0/Phaser.Physics.P2.Body.html#onBeginContact Specifically, this part: I haven't used P2 before, I am assuming that 'The Shape' is referring to the sprite you attached the body to...
  21. XekeDeath

    Moving Sprite infinite

    Have a look at TileSprite and the autoScroll function... http://phaser.io/docs/2.5.0/Phaser.TileSprite.html#autoScroll this.chain = this.game.add.tileSprite(0, 0, 24, this.game.height, 'chain'); this.chain.autoScroll(0, 25);
  22. XekeDeath

    Phaser preloader problems

    This state, to me, seems a little more complicated than it needs to be... States will call their functions in this order: preload, loadUpdate, create the loadUpdate() function is called during the loader process, you can use that instead of the timer you have... The create function is called automatically by Phaser when preloading is done... As you have the state change in the create function, it will be called as soon as preloading is done... Instead, try putting the tween to fade the text in the create function, and the state change in the onComplete callback of the tween... You can do this without changing the rest of your code, too... class Preload extends Phaser.State { preload(game,progressDisplay){ let center = { x: this.game.world.centerX, y: this.game.world.centerY }; game.load.image("player", Images.lander); game.load.spritesheet("asteroids", Images.asteroid, 64, 64, 30); game.load.onLoadStart.add(this.loadStart,this); let loadingText = new Text(this.game, center.x, center.y); loadingText.anchor.set(0.5); var timerEvt = this.game.time.events.loop(100, function (){ if(progressDisplay <= 100){ loadingText.text = 'Loading...'+(++progressDisplay)+'%'; } else{ game.time.events.remove(timerEvt); /* This isn't needed here... let loadingText = new Text(this.game, center.x, center.y); loadingText.text = 'Completed'; game.add.tween(loadingText).to({alpha: 0}, 500, Phaser.Easing.Linear.None, true); game.load.onLoadComplete.add(this.loadComplete, this); */ } }, this); } create(){ // This is copied from above, with the tween callback added... let loadingText = new Text(this.game, center.x, center.y); loadingText.text = 'Completed'; this.game.add.tween(loadingText).to({alpha: 0}, 500, Phaser.Easing.Linear.None, true).onComplete.add(function() { this.game.state.start('GameState'); }, this); //this.game.state.start('GameState'); } /* This is not needed either... loadComplete(){ this.create(); } */ }
  23. XekeDeath

    Phaser documentation issue

    This is at the top of the page... But, once you scroll down you lose sight of it... If it was in a sticky bar, it'd be cool...
  24. XekeDeath

    Best way to cut an image

    I used a sprite sheet for my puzzle here: http://xekeland.com/games/MadnessPuzzle The code is not minified, you can take a look at it in your browsers debug tools. You should also be able to look at the image and the json file for the sprite sheet.
  25. this.cards.add(card); //cards is a Phaser.Group this.card_count ++; this.game.add.existing(card);This part is your problem... You are adding them to the this.cards group, then removing them from the group and adding them to the stage... This line is not needed at all: this.game.add.existing(card); You add the this.cards group to the stage, not each individual card...