• Content count

  • Joined

  • Last visited

About Faizy

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Faizy

    Signals in Phaser

    Hey, I need some kind of a listener, which looks 24/7 if a specific event happens and triggers a function/callback. A basic example: if a player reaches position X, a function should be triggered, which adds a scorepoint. Is it possible to define a specific event, which get´s checked 24/7 if happening, and if yes, a specific function will get fired? I cant figure out where I can set up the condition, even after reading this Thanks!.
  2. Faizy

    User input(e.g. username)

    Hey, I have a very simple state: var menu = { preload: function() { console.log("Starting menu.js") game.load.image('buttonPlay', 'assets/buttonPlay.png') game.load.image('buttonScores', 'assets/buttonScores.png') game.load.image('buttonNewGame', 'assets/buttonNewGame.png') game.load.image('buttonQuit', 'assets/buttonQuit.png') }, create: function(){ this.stage.backgroundColor = '#4A4A4A' this.buttonPlay = this.add.button(game.width/2 - 100, 50, 'buttonPlay', this.play); this.buttonScores = this.add.button(game.width/2 - 100, 120, 'buttonScores', this.scores); this.buttonNewGame = this.add.button(game.width/2 - 100, 190, 'buttonNewGame', this.newGame); this.buttonQuit = this.add.button(game.width/2 - 100, 260, 'buttonQuit', this.quit); }, play: function() { console.log("play") game.state.start("Main"); }, scores: function() { console.log("scores") }, newGame: function() { console.log("newGame") }, quit: function() { console.log("quit") } } Now I want to create some kind of an inputfield(similar to HTML inputfields) so a user can type in his name. Is it possible to create fields inside(onside the) states? What would be a good solution? Thanks
  3. Faizy

    Create outside bounds

    Edit: found the solution, I had a callback when an enemie is out of bounds which killed it. Well, my question now is: is there a possible way to only check if the object is out of bounds on a specific site? Something like: enemy.events.onOutOfBoundsLeft.add(removeFromGroup, this); Hey, I want to create an enemy outside the worldbounds. The enemys position will get the velocity property: enemy.body.velocity.x = -500; so it will move from the right to the left. It all works fine, however I´m unable to create something like this(first parameter) and I think it´s due to the enemy would be outside the right bound. this.enemy = game.add.sprite(game.width + 100, y, sprite) Is there a solution to it?
  4. Faizy

    Store highscores etc.

    Hey, could someone recommend me what would be the best way to store highscores etc. from different players of my game? Right now I just want to store highscores and load them every time someone starts the game. Later on I want to save more detailed data. Any suggestions? Thank you
  5. Faizy

    How is 'this' working here?

    I have a question about how the keyword 'this' works in the following context. Here´s a [tutorial][1] with the phaser framework and the code looks like the following(I simply merged it together for you): [1]: http://www.lessmilk.com/tutorial/flappy-bird-phaser-1 var game = new Phaser.Game(400, 490); game.state.add('main', mainState); game.state.start('main'); var mainState = { preload: function() { }, create: function() { this.bird = game.add.sprite(100, 245, 'bird'); }, update: function() { }, }; In the create function there is a 'this'. I think I understand what this does, but this example proved me wrong. The this keyword - in this context- points to mainstate, right(just some information: the create function starts as soona s mainstate is called to start in the 3rd line)? I can access the bird outside the mainstate object(via *mainstate.bird*), but why isnt it possible then to to define a prototype function like the following outside the game object? mainState.prototype.myFunction() {} I´ll get an error calling this and I cant explain.
  6. Faizy

    Execute something exactly one time

    Ah, I got it now! Thank you function updateScore() { main.pipes.children.forEach(function(element, index) { if ( (element.x < main.bird.x) && (element.crossed == false) ) { console.log('Scored') element.crossed = true; } }) } But, non-related to everything above, is there a way to add a listener to a sprite for example who checks if a given condition happend and executes given code(something like an 'event' in phaser)?
  7. Faizy

    Execute something exactly one time

    Thank you Abhishek Singhal However I need something that checks the position of player.x all the time but will only execute the given code when the condition occur. I´m looking for something that checks the position all the time throughout the game and will fire a function once.
  8. Hey, let´s assume a player and a finish line. As soon as the player crosses the finish line, the console should say 'crossed'. When I would set up something like this in the update function, I will get the result every time the function fires. if (player.x > goalline.x) { console.log('crossed') } Is there a way to add something like a listener to the player which updates the positions and checks the condition, but will only fire the function once? Im sure there are multiple ways to solve this, most likely in the update function and one outside(something like an event listener). Could someone help me out?
  9. Faizy

    Kill sprites out of bounds

    Thanks a lot! I was wondering if something like this would be possible: function addSingleWall(x, y) { this.wall = game.add.sprite(x, y, 'wall') game.physics.arcade.enable(wall) wall.body.velocity.x = -400; wall.checkWorldBounds = true; wall.events.onOutOfBounds.add(function() {wall.destroy()}, this); main.walls.add(wall) } It works, but it destroys the wrong wall, which makes sense. So my question(in general) is: how do I know which wall is out of bounds, so i can set it up to get destroyed(?). IOt´s probabaly a returned value, but I cant get the grasp of it Ah, got it from an example! Does that mean, that onOutOfBounds returns the outOfBounds object(in this case the wall) and passes it to the function which is about to get fired? I couldn´t really get that from the documentation nor the Phaser API...or am I missing something?
  10. Faizy

    Kill sprites out of bounds

    Hey, let´s assume you have a wall going from the right to the left. The wall is stored in a group called walls. I want to kill/destroy/remove the wall from the group(groups children) as soon as it is out of bounds(on the left). I tried the following, however it didn´t work, since the children are still there and the groups.length is increasing. function addSingleWall(x, y) { this.wall = game.add.sprite(x, y, 'wall') game.physics.arcade.enable(wall) //wall.body.immovable = true; wall.body.velocity.x = -400; wall.checkWorldBounds = true; wall.outOfBoundsKill = true; main.walls.add(wall) } Could someone help me out?
  11. Faizy

    Using 'this' instead of game

    Hey, I know what the word *this* does. However I dont know why so many tutorials use 'this' instead of 'game'(or whatever your objectname is called...let´s just assume it´s called 'game'). See this for example. // Variable to store the arrow key pressed this.cursor = game.input.keyboard.createCursorKeys(); // Create the player in the middle of the game this.player = game.add.sprite(70, 100, 'player'); // Add gravity to make it fall this.player.body.gravity.y = 600; Instead of creating 'var player' he(the guy who wrote this tutorial) creates properties of the object 'game'. Is there any benefit to doing it like so? Or is it just because it´s OOP?
  12. Faizy

    Multiple spritesheets

    Thank you. I already thought about that option, but I thought it would cost to much performance. Any example(code) where this was archieved?
  13. Faizy

    Multiple spritesheets

    Hey, I have a spritesheet which has different sizes for each sprite(like this one for example, as you can see they are differences in the size of each frame ). Let´s assume I have a spritesheet called "running" and one called "jumping", the first one is 50x50 and the second one is 50x70. Since they have different sizes, I added them separately into the game. Both animations work fine. The problem I have now is, that I see every spritesheet all the time, since I have to add them into the game, meaning all the animations/different spritesheets are overlapping. 1. Is there a better way to solve the Problem of different sized spritesheets? 2. What would be a good solution to my problem? Thank you and have a nice weekend
  14. Faizy

    How to define gamesize?

    Hey, I want my game to be the size of the white area(as linked below) and the grey area should still be able to interact with the game(white area) via (Phaser-)buttons etc. meanwhile the gamestage/gamearea should only be on the white rectangular. Is that possible? I´m looking for something to create "walls". https://gyazo.com/81b7432d89f108a0b15c231e1ab6f4bc Thank you
  15. Faizy

    Add buttons outside the game

    Thanks rich. Wel,; I´ll ask another question, assuming the following: var game = new Phaser.Game(800, 600, Phaser.Auto, '', { preload: preload, create: create, update: update } ); Is it possible to ONLY use 700px instead of 800px width? I would use the 100px to place my buttons there. Is there a way to say phaser that the game, where everything happens, is only 700px width?