Sawyer

Members
  • Content Count

    23
  • Joined

  • Last visited

About Sawyer

  • Rank
    Member

Recent Profile Visitors

523 profile views
  1. Sawyer

    Check if path is blocked

    Thanks guys That raycasting example worked perfectly @samid737
  2. Sawyer

    Check if path is blocked

    Hi Guys I'm working on a top down shooter. I have AI that uses angleBetween to face the direction of enemies when they spawn. The game uses a tilemap with some collisions randomly spawned around the map. Is there a way that I can detect if there's a collision layer blocking the path between my AI and enemy sprites? I don't want my AI to mindlessly fire their weapon if the enemy is behind a wall. in my AI.js I have: AI.Prototype.update = function() { ... this.rotation = game.physics.arcade.angleBetween(this, this.closestEnemy); ... **Checks if enemy exists on map, uses Phaser weapon plugin** this.pistol.fire(); }; Would I need to implement pathfinding to check if there's a direct path before firing or is there an easier way to go about this?
  3. Sawyer

    Import TileMap with collection of images

    Phasers documentation says; So you could load each image individually then call; map.addTilesetImage(); For each of your tilesets
  4. Sawyer

    Remove keyboard callback

    I have an opening screen to my game where the use can press any key to start. I implemented this using: this.game.input.keyboard.addCallbacks(this, function() { this.state.start("Menu"); }); My problem is that this callback persists over into other states, so if I press any key it always take me back to my Menu state. I've looked at the Documentation and tried both: this.game.input.keyboard.addCallbacks(this, null, null, null); and this.game.input.keyboard.reset(true); Neither of which did the trick. I then simply replaced the callback with: this.game.input.keyboard.addCallbacks(this, function() {}); Which seems to have solved the problem. 2 questions here: Is there a cleaner way to do this? Would having an empty callback like this impact performance in any way?
  5. Sawyer

    Changing Physics Bounds for Animations

    Thanks Taggrin, I'll give it a try! my main problem is that my walking animation is much narrower than my attack one, so it was putting collision way off when walking into walls and stuff but your way definitely sounds promising
  6. I have a sprite sheet of my games playable character. The frames consist of all possible actions the character can do, including two different attacks. I want to change the physics bounds on different animations as my sprites positioning obviously changes with different animations. I got PhysicsEditor expecting it could handle this but as far as I can see, it only works for single images. Is there any solutions for this to help me get near pixel perfect collision? Any help is appreciated as always
  7. Sawyer

    Auto generating levels with Tiled

    Thanks @drhayes, I'll have to rethink my strategy towards this and start building it again from scratch . Clever thinking with the separate Object Layers, I'll give that a try.
  8. I'm creating a game using tilemaps. Every level is designed similarly which contains chests and levers to open gates. I thought it would be a good idea to set up some global objects, such as levelSetup, which passes in the tilemap for that level to reduce the code for each state. levelSetup( ) adds the player, levers and chests, while I also have a globalObjects function which handles collisions and everything else for the player. I've only just realised that I now have some problems with this way about things. The main one being; How could I tell the current level (state) when a specific lever is pulled from the global function so I can open the corresponding gate?
  9. Sawyer

    Pathfinding tools for Tiled

    Thanks guys I'll look in to pathfinding.js Jackolantern. It's a team project and we have multiple collision layers (for several reasons). I guess if needs be, I could add a new transparent collision layer over all of them to use for pathfinding
  10. Sawyer

    Pathfinding tools for Tiled

    I've used Tiled to create my levels in Phaser. I want to implement some AI Pathfinding. I've looked at EasyStar.js and seen it needs an array of which tiles are walkable. I have several layers and quite large maps so this would be a very long process to have to do manually. Is there an easier way to do basic pathfinding with Tiled?
  11. Sawyer

    Player selection

    Thanks AzraelTycka, this may help solve my problem. I never thought about setting it globally. I will try this tomorrow
  12. Sawyer

    Player selection

    Thanks for the reply Skeptron. I looked at the examples but I still can't figure out what I'm trying to do. My scenerio: In my game state I have a player variable, I want this to be declared as whatever character is chosen in the previous state, say char1, char2 or char3. I want to be able to simple call player.moveLeft( );which will call the appropriate object's function. I've looked at the example but since they're just recreating the same object, I'm not really sure how to go about it. Would it work by serialising the selected object into LocalStorage then calling it in the game.js?
  13. Sawyer

    Player selection

    I'm making a simple side scrolling game that allows the player to choose their character at the beginning. Each character is from a different spritesheet, having different frames and sounds for each possible animation. How would I go about persisting this selection throughout the game? In an OOP world, I would make a Player class and inherit it into objects of each possible characeter, overriding the methods for each action the player can make, passing the chosen action between classes. How can I do this in Phaser/JS world? I'm guessing I do something along the same lines by creating a custom object, but I'm not sure exactly how to go about this. Any help will be appreciated.
  14. Sawyer

    Text not showing on state change

    Hey chongdashu, Fixed the typos, the one missing the quotes was a mistake typing in the question but the problem persisted. I logged the text and found out that the coordinates weren't being set for some reason. I tested by just setting them to (200, 200) and the text appears. Not really sure why this.world.centerX and Y weren't working. EDIT: Figured it out. In my game, I resize the world to be the width of my wide scrolling map, so when I set centerX, it's being placed way out of bounds of the original frame.
  15. I have a game working using states. It goes from the preload state to the menu, to the game. When the game loads it displays the text fine, where I can click it to start the game. However, when the player dies I start the preload sequence again. The state loads but the text never appears. It appears to be still there as I can click on the screen to start the game again but I just have a black screen. I tried adding a tryAgain state to go to this instead but the issue persists. game.js MyGame.GameState.prototype = { create: function() { .... }, update: function() { if (this.health == 0) { this.state.start(tryAgainState) } }tryAgain.js MyGame.TryAgainState = function (game) { this.label;}; MyGame.tryAgainState.prototype = { create: function() { this.label = this.add.text(this.world.centerX, this.world.centerY, "Start Over", { font: "65px Arial", fill: "white", align: "center" }); this.label.anchor.set(0.5); this.label.inputEnabled = true; this.input.onDown.add(this.startOver, this); }, startOver: function() { this.state.start("mainGameState"); }}