casey

Members
  • Content Count

    94
  • Joined

  • Last visited

Everything posted by casey

  1. I don't think you'll find a physical book, only e-books because frameworks change so quickly that once it's printed it's out of date. E-books can be updated by the authors more easily. But if you want a hard copy, buy an e-book and print it. I second Feronato's site and books. You can find tutorials on different HTML5 frameworks available there.
  2. Thanks. I don't want to actually rotate the falling object, only have it slide, but I'll see what I can do with P2.
  3. If you can't read the variable from your HTML in another javascript (I'm sure you can but I haven't tried): You could write the score as a local file in localStorage using the set method (http://www.thebotanistgame.com/blog/2015/08/12/saving-loading-game-state-phaserjs.html) Then you could read it from your html using a short script to get the localstorage info by name. https://developer.mozilla.org/en-US/docs/Web/API/Storage/getItem
  4. I have a platform where the platform will start tipping (rotating) when the player jumps on it, tipping the player off. The platform rotates now, but the player's gravity doesn't come into effect when the platform rotates--the player stays standing in the air. I can disable the platform body, and the player will fall through, but I want the player's body to move along the platform (slide off). What am I missing? var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update }); function preload() { game.load.image('ground', 'platform.png'); game.load.spritesheet('dude', 'dude.png', 32, 48); } var player; var ledge; function create() { game.physics.startSystem(Phaser.Physics.ARCADE); ledge = game.add.sprite(0, 400, 'ground'); player = game.add.sprite(20, 20, 'dude'); game.physics.arcade.enable([ledge, player]); ledge.body.immovable = true; ledge.body.allowGravity = false; player.body.gravity.y = 200; cursors = game.input.keyboard.createCursorKeys(); } function update() { this.physics.arcade.collide(player, ledge); player.body.velocity.x = 0; if (cursors.left.isDown) { player.body.velocity.x = -150; } else cursors.right.isDown) { player.body.velocity.x = 150; } //when player goes half way start sliding if(player.body.x > 200){ ledge.angle += 0.5; //ledge.body.enable = false; } }
  5. This is the Phaser 2 forum... try the Phaser 3 forum!
  6. Did it work with a regular function (i.e. not a callback?)
  7. Check out the particles plugin, as well. It can do this for you. https://phaser.io/shop/plugins/particlestorm
  8. I dont' know Vue.JS but it looks like you're missing a comma after your render function.
  9. I don't have an answer for you, osrry. I suppose one way to narrow the problem down would be to see if it works on other versions of Chrome for Linux, and see what was changed in the updates. Pain in the arse, I know, but then this stuff sometimes is. I would also try a LInux/Chrome forum.
  10. Did you do previous testing in Firefox? Is it possible that Firefox is loading from cache and there is an issue in your code? Does it work in Chrome without the bundler?
  11. Full tutorial here: https://www.joshmorony.com/adding-custom-fonts-to-your-phaser-game/
  12. How are you doing the reset exactly?
  13. I don't have time to go through all that, but for a few bucks you can get the complete source code to one here: http://www.emanueleferonato.com/2017/08/22/learn-to-create-html5-cross-platform-games-using-phaser-ladderz-game-completely-commented-source-code-available/
  14. https://codepen.io/jdnichollsc/pen/WbZgwM https://phaser.io/examples/v2/input/drag-event-parameters
  15. Do you mean from within your code? You'd have to extract the filenames that are inside your JSON. Doing that would depend on how the JSON is structured. Externally, you can just open your JSON file and look at it and the filenames will match your filenames of the files that went into the atlas.
  16. Actually I just needed to do e.loadTexture("on") in the pickMe function. Thanks for your help samme
  17. That's what I'm trying to do. I'm not able to get the index of the tile. I can log out the column and the row, and get the value of the tile picked, but I'm not able to refer to the texture of the tile at the index.
  18. This might be better answered on a Cocoon rather than Phaser forum. I haven't used Cocoon, but Phaser (and I believe Cocoon) is just essentially an in-browser game so you just store data like you would any browser data using LocalStroage. https://developer.mozilla.org/en-US/docs/Web/API/Web_Storage_API#localStorage
  19. Thanks, so..... how do I get the right index in order to change the texture of that particular tile?
  20. Nobody? I'm correctly getting the right tile to change in pickedTile, but if I do this.grid.indexOf(this.pickedTile) it always just returns -1.
  21. I'm having a brainfart. I've got a grid of 6x6 tiles. When the user clicks a tile, I want to turn it on (if it's off) and off (if it's on). While I can get the right tile picked and change the array value, I'm having trouble updating the image of the picked tile: instead, it always changes the last tile created. How do I fix my pickMe function so that the correct tile changes image from off to on? ar titles ={ preload: function(){ this.game.load.image('on', 'on.png'); this.game.load.image('off', 'off.png'); }, create: function(){ var cols = 6; //number of columns var rows = 6; //number of rows var tilesize = 45; //size of tile in px //game grid this.grid = []; var i,j; for(i = 0; i < rows; i++) { //push in empty array this.grid.push([]); for(j = 0; j < cols; j++) { //set initial value to zero this.grid[i].push(0); this.addTile(i, j); } } }, //creates the initial grid addTile: function(row, col){ //position according to tile size var tileXPos = (col * 45) + (45/2); var tileYPos = (row * 45) + (45/2); //add image, set to off at start this.myTile = this.game.add.image(tileXPos, tileYPos, "off"); //set anchor to centre this.myTile.anchor.set(0.5); this.myTile.inputEnabled = true; this.myTile.events.onInputDown.add(this.pickMe, this); }, pickMe: function(e){ var pickedCol = Math.floor(e.x / 45); var pickedRow = Math.floor(e.y / 45); //this returns value of tile at pickedTile in grid this.pickedTile = this.grid[pickedRow][pickedCol]; //if it's off, turn it on, and vice versa if(this.pickedTile === 0){ this.grid[pickedRow][pickedCol] = 1; } else{ this.grid[pickedRow][pickedCol] = 0; } console.log(this.grid); } };
  22. I also recommend starting with Phaser 2. There's a lot more documentation and experienced support out there for it. It's not that hard to switch later.
  23. I don't believe it's possible. https://stackoverflow.com/questions/43440882/can-javascript-detect-if-a-mobile-device-is-muted In Chrome, it's possible to determine if a browser tab is muted, but not the device itself. That information is just not available to the browser.
  24. I agree --way faster in both your time and processing time to just tag it that way in code.