cammil

Members
  • Content Count

    8
  • Joined

  • Last visited

  1. Should non-gamelike functionality be implemented in phaser or in standard html? For example, logins, joining games in multiplayer games are functions required by the game, but are not part of the game itself. Some background to my project: I am currently investigating framework options for a multiplayer web game. There will need to be logins, and the players will need to be able to choose opponents. The game will be turn-based and not real time.
  2. Yes, that seems like the best solution. Thanks for the help!
  3. Setup: There are multiple display objects which are at the same level on the scene hierarchy graph. These display objects have overlapping hit areas (e.g. they are near each other and/or the hit areas are large) The user touches the area where the hit areas intersect It seems that pixi will trigger the touchstart event on only one of these display objects. How do I get the event to fire on both? My Goal: I have multiple objects which the user can drag around the scene. However, I want to allow the user to be quite inaccurate with their finger, so that if they attempt to drag an object which is near, AND there is no object directly underneath their finger, that object will be picked up successfully. If there are multiple object near the event, then the closest one should be picked up. This is the motivation for the above question.
  4. This is an extremely clear and helpful answer. Many thanks.
  5. I have seen game states being constructed in a few different ways: // the game object is an argument of the constructor, and also property of the statevar state1 = function(game){ this.preload = function(){ this.game.load.image('img1', 'assets/img1.png'); ... } ...};// the state appears to be synonymous with the game objectvar state2 = function(){ this.preload = function(){ this.load.image('img1', 'assets/img1.png'); ... } ...};Both appear to work, though I don't understand why. Could someone enlighten me? Also, are there recommendations as to which one would be better? Or what are their relative pros and cons? (I might be able to answer this myself if I understood why both work!)
  6. I seem to have a problem with tiles disappearing when the camera scrolls. The tiles below that have been given an alpha property will disappear when the camera scrolls. I have tested this in Chrome and Firefox. In Chrome the tiles disappear completely. In Firefox, they just blur. Is this a bug? var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render }); function preload() { game.load.image('ground', 'assets/ground_32.png'); game.load.image('ground2', 'assets/ground2_32.png'); game.load.spritesheet('dude', 'assets/ufo.png'); } var map; var map_size_x = 40; var map_size_y = 40; var layer1; var cursors; var player; var player_speed = 290; function create() { game.stage.backgroundColor = '#2d2d2d'; game.physics.startSystem(Phaser.Physics.ARCADE); // Creates a blank tilemap map = game.add.tilemap(); map.addTilesetImage('ground2'); // Creates a new blank layer and sets the map dimensions. // In this case the map is 40x30 tiles in size and the tiles are 32x32 pixels in size. layer1 = map.create('level1', map_size_x, map_size_y, 32, 32); // ground layer2 = map.createBlankLayer('level2', map_size_x, map_size_y, 32, 32); // objects // Resize the world layer1.resizeWorld(); layer1.debug = true; //layer2.debug = true; var prob_passable = 0.9; for(var i=0; i<map_size_x; i++){ for(var j=0; j<map_size_x; j++){ var tile1 = map.putTile(4+20*2, i, j, layer1); if(Math.random() >= prob_passable){ var tile2 = map.putTile(9+20*9, i, j, layer2); tile2.setCollision(true, true, true, true); tile2.alpha = 0.5; } } } player = game.add.sprite(50, 120, 'dude'); game.physics.arcade.enable(player); player.body.collideWorldBounds = true; game.camera.follow(player); cursors = game.input.keyboard.createCursorKeys(); } function update() { game.physics.arcade.collide(player, layer1); player.body.velocity.x = 0; player.body.velocity.y = 0; var dx = 0; var dy = 0; if (cursors.left.isDown) { dx = -1; } else if (cursors.right.isDown){ dx = 1; } if (cursors.up.isDown){ dy = -1; } else if (cursors.down.isDown){ dy = 1; } var d = Math.pow(dx*dx+dy*dy, 0.5); player.body.velocity.x = player_speed * dx / d; player.body.velocity.y = player_speed * dy / d; } function render() { //game.debug.bodyInfo(player, 32, 320); }
  7. I'm just working through the first tutorial, and also looking at the phaser examples. I often get this error in my js console log: GET http://localhost:8080/js/phaser.map 404 (Not Found) (I've also just installed node and have no experience with node either!) Does anyone have any ideas about what I am doing wrong?