• Content count

  • Joined

  • Last visited

  • Days Won


BdR last won the day on July 2 2016

BdR had the most liked content!


About BdR

  • Rank
    Advanced Member

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    The Netherlands

Recent Profile Visitors

3,078 profile views
  1. BdR

    I need help closing my score in a Pong game

    What exactly is not working in your current program? I don't think you need to check the win-condition in the update() function. If you do it in the update() then it will be checked for every frame, you only need to check if there is a winner on the moment that a point is scored. I would add an extra variable that remembers if the game is still in progress or if it's gameover and there is a winner. See the "iswinner" variable in code below. /*global Phaser,*/ var clavier, Joueur2, Joueur1, Balle, iswinner, texte //etc. var etat = { //.. create: function () { iswinner = 0; // 0=no winner, 1=player 1 wins, 2=player 2 wins this.winimage =, 100, "winimage"); this.winimage.visible = false; //etc. }, update: function () { //.. if (iswinner == 0) { if (Balle.body.blocked.right) { Point1 += 1;"Point1!"); this.checkWinner(1); } else if (Balle.body.blocked.left) { Point2 += 1;"Point2!"); this.checkWinner(2); } else if //.. etc. } }, checkWinner: function (plr) { if (Point1 >= 2 || Point2 >= 2) { // remember which winner iswinner = (Point1 >= 2 ? 1 : 2); // 1 or 2 // set text Balle.body.velocity.setTo(0, 0); texte.text = 'Game Over! Player ' + iswinner + ' wins!'; texte.visible = true; this.winimage.visible = true; } else { // continue game, reset ball Balle.x = 240; // center Balle.body.velocity.setTo(400, 450); } }
  2. BdR

    Dismemberment function, any advices ?

    Not advice but a question, why do you need 6 bitmaps? Can't it just be 6 sprites? That's probably less taxing on performance.
  3. @onlycape The autoDecode is optional and defaults to true, so that is already the situation in my first post. I guess my quesion boils down to this: If my game state is like so: mygame.GameState.prototype = {  create: function() { // add sound effects this.sound1 ="button"); //etc. }, What happens when I do"button") in the .create() method? Specifically what will happen when the State is restarted like 50 times or more? Will Phaser load & reserve memory etc. 50 times for the same sample? Will this impact overall performance?
  4. I've made a sandbox with the StateManager restarting a State and using samples -> However the sandbox is running Phaser 2.6.2 so I couldn't reproduce the warning "Audio source already exists" because that warning is not in the 2.6.2 release. Anyway, I use mp3 and ogg samples for the sound effects and I suspect it has to do with decoding the sounds. My question is: do I have to decode the sound samples every time the player starts (or restarts) a level i.e. restart the GameState? In other words, if the GameState will be .create() each time a level is (re)started, will the decoded samples be destroyed and have to be reloaded each time? That seems wasteful, what is the best way to do this?
  5. @onlycape Thanks I got it to work by looking at that example ->
  6. I'm trying to run one of the Phaser examples in a sandbox to reproduce an audio question by running an altered version of this audio example in the sandbox. I've altered the code (see link to sandbox below) but when I click the Play tab, the console shows this error message. So it seems the sandbox cannot run Phaser games that make use of the StateManager. Should the sandbox be used in another way for the game.State to work? Am I doing something wrong here? See saved sandbox ->
  7. Thanks, but no that is not it. It's just an example code snippet. The actual code in my game is correctly calling it just once. There is always a few seconds between playing the sound effect again, and by then the previous sample playback is already finished. But still the "Phaser.Sound: Audio source already exists" warning appears.
  8. I'm a bit confused about loading and playing sound effects. My game is setup in different states, first the Preloader state makes sure all images and sounds are loaded. The GameState is the main game, this state is re-started for each next level. There are different levels but the state is the same, it just changes a _levelIndex variable and uses the same state. The GameState adds the needed audio to the game in the .create() function, and this create() function is called every time the GameState is started. See code below mygame.Preloader.prototype = { preload: function(){ this.loadingbar_bg = this.add.sprite(80, 512, "loadingbar_bg"); this.loadingbar_fill = this.add.sprite(80, 512, "loadingbar_fill"); this.load.setPreloadSprite(this.loadingbar_fill); // load sounds"button", ["snd/button.mp3", "snd/button.ogg"]);"punch", ["snd/punch.mp3", "snd/punch.ogg"]);"coin", ["snd/coin.mp3", "snd/coin.ogg"]); }, create: function() { this.state.start("MainGame"); }, }; mygame.GameState.prototype = { create: function() { this.stage.backgroundColor = "#f0f"; // etc. // sound effects this.sound1 ="button"); this.sound2 ="punch"); this.sound3 ="coin"); //etc. }, update: function() { if (hitFace); }, doNextLevel: function() {; this._levelIndex++; // next level this.state.start("MainGame"); // restart this state }, //etc. }; The problem is that when I play the punch sound a couple of times in a row, the console gives this warning: Phaser.Sound: Audio source already exists which Phaser raises in code here. This warning appears even when the GameState is started for the first time. So my questions are: 1) What does this message "Audio source already exists" mean ? Or should I ignore it? 2) if I want to use a sound in a state, do I have to re-add it every time the state is started and .create() is called ? 3) also somewhat related, if I want to use the same sound sample in multiple different States (menu, game, options etc.) do I have to it for each state?
  9. @samme thanks that also works and seems to me is more to the point of the problem.👍 I've now changed my code like so: create: function() { // code.. // fix canvas focus keyboard issue, this); }, doFocusFix: function() { window.focus(); },
  10. Thanks for the tip, I don't really know what it does exactly, but it fixed my probem. I mean I'm running the game in Chrome, so I don't get why stopping the event listeners on an MSPointer fixes this issue, but well.. here we are. Seeing as it's the same code for both pause and unpause, this is what I've added to my game and now it's working again: create: function() { // code.. // fix issue; keyboard doesn't work after canvas lost focus, this);, this); }, doPausedUnpaused: function() { },
  11. I've created a page to isolate and reproduce this issue, see keyboard test edit: I just noticed that you can manually set the focus back to the canvas using the TAB button. So in the "keyboard test" page, press the "do something" button (which is outside the iframe) then OK on the alert pop-up, then press TAB once and the focus is back on the canvas and keyboard events work again. What I expected was that when you mouse-click inside the canvas, the canvas should also get focus for keyboard events again, but this is not the case. I don't expect the average player to know this or figure this out, so how can I realise this?
  12. Question about keyboard controls. I'm working on a simple action game in Phaser CE, the player touches certain parts of the screen to do various actions. The mouse/touch input parts work fine and now I also want to support keyboard input for people playing on desktop. The problem is; the game is running inside an iframe and the keyboard input works correctly until the canvas loses focus. The game pauses which is correct behaviour, then I click inside canvas again, game continues and mouse input still works. But now the keyboard input is not working anymore. When the game is not running inside an iframe this is not a problem, the keyboard continues to work after losing focus, pausing and then continuing. Do I have to use something other than "game.input.keyboard.addCallbacks" to check for keyboard input? This is my code mygame.GameState.prototype = { create: function() { this.stage.backgroundColor = "#f0f"; this._levelindex = 0; // .. // etc. // game input for mouse and keyboard, this); // mouse/touch, this.doGameKeyInput, null, null); // keyboard // .. }, onGameMouseDown: function(evt) { // code.. ok works fine }, doGameKeyInput: function(key) { var kc = key.keyCode; var action = 0; if (kc == 32) {action = 1}; // space if (kc == 90) {action = 2}; // Z if (kc == 88) {action = 3}; // X // etc. this works until canvas loses focus } } FYI i'm using Windows 10 and Chrome
  13. BdR

    Tap Tap Plane

    Looks cool, but wasn't this originally developed as a Phaser2 game first? I like how the chimes go up and up in pitch as you get the stars consecutively. But when it's at the highest pitch, I think it should also display a "+1" bonus or something. You know, similar to Super Mario when you consecutively jump on turtles to get 1-ups.
  14. I've been working on Impossible Snake 2 for a while now and at this point I feel it's finished. You can play a 9 level preview demo in the link below. Impossible Snake 2 demo It is the sequel to Impossible Snake and it's a one-button snake game. You control the snake with only a single tap to change its direction, each time you tap the snake will toggle between turning clockwise and counter-clockwise. So in a way the controls are similar to Flappy Bird. Eat all apples to open the exit, go through the exit to complete the level. There are bonus coins in difficult to reach spots to add an extra challenge. There are some new features compared to the first Impossible Snake: Go through the exit to complete a level Collect bonus coins for an extra challenge Moving spark enemies, avoid them or you'll get electrocuted Laser beams, some can be switched on and off 27 levels + 9 bonus levels 3 different background themes Some sound & graphics tweaks Btw looking back I don't know why I didn't include screen shake in the previous game, as it's simply built into Phaser. It was just adding one line of code but it gives that much more *oomph* when you hit a wall. 😆 Anyway let me know what you think of the game.
  15. Just a small update for anyone interested. Recently I picked up this video editing again and tried to make a walkthrough video for my webgame Impossible Snake. This time I figured it out. I recorded in OBStudio and then edit it in ShotCut. I didn't use OpenShot, it's an okay video editor but feels a bit too simple and limited when compared to ShotCut. You can records webgames and desktop application etc. OBStudio, I did the following steps: under sources add "Display Capture" and "Desktop Audio" right click "Display Capture" and select Filters add a Crop/Pad filter and set the margins go to in Settings -> Video, set "Base (Sanvas)" and "Output (Scaled)" resolutions to match your cropped region hit "Start Recording" and play your game I'm now trying to create a GIF animation of a short game play clip, using the tips here -> How To Create A Gif To Show Off Your Indie Game