Jump to content


  • Content Count

  • Joined

  • Last visited

Posts posted by drunkenoodle

  1. Mornin',

    Frankly (in my personal opinion), I wouldn't worry about integrations and builds with Phaser until you've got a good grasp on how it generally works. You don't need to use TS to use Phaser basically, so I'd just dive in and start monkeying around with it using standard JS at this stage (looking at the examples, other sites such as game mechanic explorer as a starting point). Otherwise you're going to scare yourself away, as there's a lot to learn. But taking it step by step will allow you to keep your confidence and keep the fun aspect of it all in check.

    However, that being said, you could very much benefit from looking at TypeScript also. In brief it's a 'superset' of JS that keeps you on the straight and narrow, allowing for best practices when it comes to compiling down to actual JS (that's a very very brief summary). Also, you briefly mentioned Node.js, you can also write apps for it using Typescript too (since it's just JS at the end of the day).

    So, in short, don't worry too much about the details just yet. Getting a grasp is a great place to start, so if I were you I'd get your hands dirty with Phaser, and if you've got time have a look at how TS works. Then, when you're confident on both, you can bring them together in a sublime union of magical intrigue.

    I hope this helps in some way to take you forwards, and feel free to PM me for any extra help.

    Good luck out there! 


  2. runnerscreenshot.jpg


    Hi everyone, just wanted to post up a cheeky link to a game myself and a colleague knocked together within a week or two for the company we work for (Shout Digital). It was decided that a series of christmassy things needed to happen and this was one of the ideas that came to light.

    It uses a combination of Phaser (of course!) and chance.js to pre-generate pretty much all of what you see passing you by at the start of the game.

    Direct game link is here: http://runner.shoutdigital.com/

    Unfortunately we ran out of time when it came to making the code nice and clean, plus sticking handheld device functionality in there. But hey, I think it turned out adequate in the end. 

    Much thanks to the grand efforts on Phaser, and have a great Christmas everyone!

    P.S - Runs best on Chrome and Firefox (we had trouble with pixel sharpness on IE) ; ;


  3. Hey everyone,

    I stepped upon an interesting thing or self induced bug that seems to be happening whilst using Arcade Physics for an infinite runner. It's pretty rough around the edges, more of a proof of concept than anything else, but basically in the update function I'm doing a couple of things.

    First of all, the ground is a group of child sprites, each ones velocity gets nudged left per update cycle:

    this.ground.children.forEach(function(c) {
       c.body.velocity.x = -this.RUN_SPEED;
    }, this);

    Then, I check to see if any of those children have gone off screen to the left (child.body.right < 0) for example. Once that's done, I then reset that child back to the right hand side of the screen like so:

    child.reset(this.game.width, child.y);    

    In between all that I just do a couple of checks to make sure none of them overlap, by using this (it also makes sure we don't try to place anything else whilst this particular piece is still leaving the right-hand area:

       return child.x < this.game.width && child.x + child.width > this.game.width || child.x >= this.game.width;
    }, this);

    Now the main problem I'm having is that there seems to be a gap between each one of the sprites when they've been resetted and are following the one that came before hand. What I find interesting is that if I set the velocity to 256, the gap between each sprite seems to be exactly 12 pixels in width. If I drop it to 128, then it drops to 6 pixels in width. 

    I'm curious as to how the numbers might correlate, or, is there something that happens in the physics step that's making the gap outside of the main update loop? It's a bit of a weird problem, and as said earlier, it's probably just down to poor implementation.

    I've attached the script file if you'd fancy a perusal also.

    Thanks for your time everyone, take care!


  4. Hello all,

    Just wondering if the tileMapLayer is supposed to have the 'bringToTop' method in it still? I updated my version of Phaser to 2.3.0, and discovered that it no longer existed.


    Is this supposed to be the case? Currently I'm just hacking it a bit and doing:

    Phaser.TilemapLayer.prototype.bringToTop = Phaser.Component.BringToTop.prototype.bringToTop;

    Just wondered in case things had been changed, or if it was done by mistake.



  5. Hello everyone,

    If anyone's interested in progress I'll keep updating this topic with what I discover about side-on staircases. Code is to follow when I finally get it working nice and smoothly.


    So far I've got a few things sorted out in regards to my problem. Basically what I decided to do was have a series of different tile types (on a collision layer) that will handle the transition between being on a stair case and not at all. What this allows for is a mode change on the player sprite.


    For example, upon entering the staircase (either top or bottom), the mode of the player sprite is changed to 'staircase', this allows me to modify the tile callbacks to behave slightly differently. In this case, the collisions are mostly disabled and the sprite is forced to move at a 45 degree angle in either direction (to give the feel of climbing a or descending a slope). For the most part this seems to work quite well.


    Another factor to consider is if say you have quite a wide staircase, if you're going to press the up or down keys, you might expect to be able to walk from top to bottom. Rather than be forced to still travel at a 45 degree angle. Again, I've been getting around this (so far) by disabling velocity upwards or downwards depending on if you're stood on an 'edge' tile. This has presented a few problems, as disabling y-velocity while travelling at a 45 degree angle will produce some strange results (trying to move something that you've told not to move basically).


    Hopefully that makes sense to anyone who's interested. I'll forward some code and whatnot when it's working smoothly, as I'm still getting my head around it all...



  6. Hey Mikau, thanks for your reply! I have actually already been using the script that's provided on that post (and it works great), so for that much it does actually work. The main problem seems to be entering and exiting however. I'm going to attempt at using some sort of 'floor sensor' then report back here with what I find out...



  7. Hello everyone,

    I've been working on a little something for a while now (top-down classic rpg) using phaser. For the most part it works quite well, but there is just one thing that I can't seem to get the hang of...


    Side-on staircases.


    Forward facing staircases are no problem at all, but the real challenge comes when attempting to create side on stair cases like we see in the image attached.


    I've made progress enough to get the player sprite to move up and down at a 45 degree angle, and 'almost' so that you aren't able to walk off the edges and only each end. But it's very tacky and feels hacked together, since it's using a simple check of tile properties to determine whether they are a staircase tile or not.


    When variation comes in to it, the whole thing falls apart, considering all the different types of staircases / entrances or exits you might have. It's particularly challenging since I'm using arcade physics, I was thinking of moving to P2 so I can do a polygon check instead, thus allowing you to only travel 45 degrees while stood on that particular area.


    Has anyone else come across this problem before? Am I perhaps missing a blatantly obvious answer (aside just not bothering at all)? :)


    Many thanks



  8. Hello everyone,

    I've been looking in to how one might create sloping tiles in Phaser.js and its Arcade physics engine. From what I've done so far, I just basically have two squares moving through the middle of an existing square as an experiment to see if my 'limited' knowledge of maths actually works (see fiddle):



    My plan was to simply move a sprite along that same trajectory while ignoring the left and right collisions of the tile...


    So I gave it a shot and attempted to apply the method to Phaser, although had very little luck doing so. I've checked out a few articles but sadly don't 100% understand them yet, so heading back to them after posting this.


    I just wondered if anyone else had any luck, and if you may have some pointers on how to go about it.


    Cheers for your time guys,


  9. Hello everyone,

    I wondered what the best course of action might be if you're using RequireJS with Phaser and wanting to access groups from other scripts. For instance, on the 'create' method (currently housed in its own script file) I have a bunch of groups that exist, but they only exist within that context, and it would be great to be able to access them say from another area that handles the game's update loop, etc.


    Current all I'm doing is this, it does work, but I can't help but wonder that it's not a nice way of doing it:

    this.game.groups = {};// And the groupsthis.game.groups.explosions = explosions;this.game.groups.damageHits = damageHits;

    Have any of you guys run in to this before?


    Many thanks,

    - D

  10. Hello everyone,
    I've recently been having a mess around with one of the Phaser game examples (Invaders), with a mind to changing it in to a side-scrolling space shooter. I'm having a bit of an issue early on however in that when I press the left and up arrow keys, and then press space bar to fire, it doesn't seem to pick up the space bar press event.


    I wondered if anyone else has had a similar issue, or, perhaps has a solution to it. Please see the source code below (input events are currently in the update method):

    var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-sidescroller', { preload: preload, create: create, update: update, render: render });function preload() {    game.load.image('bullet', 'assets/bullet.png');    game.load.image('enemyBullet', 'assets/enemy-bullet.png');    game.load.spritesheet('invader', 'assets/invader32x32x4.png', 32, 32);    game.load.image('ship', 'assets/player.png');    game.load.spritesheet('kaboom', 'assets/explode.png', 128, 128);    game.load.image('starfield', 'assets/starfield.png');    game.load.image('background', 'assets/background2.png');}var player;var aliens;var bulletsBeta;var bulletTime = 0;var playerSpeed = 3;var cursors;var fireButton;var explosions;var starfield;var score = 0;var scoreString = '';var scoreText;var lives;var enemyBullet;var firingTimer = 0;var stateText;var livingEnemies = [];function create() {    game.physics.startSystem(Phaser.Physics.ARCADE);    //  The scrolling starfield background    starfield = game.add.tileSprite(0, 0, 800, 600, 'starfield');    //  Our bullet group(s)    bulletsBeta = game.add.group();    bulletsBeta.enableBody = true;    bulletsBeta.physicsBodyType = Phaser.Physics.ARCADE;    bulletsBeta.createMultiple(30, 'bullet');    bulletsBeta.setAll('anchor.x', 0.5);    bulletsBeta.setAll('anchor.y', 1);    bulletsBeta.setAll('outOfBoundsKill', true);    bulletsBeta.setAll('checkWorldBounds', true);    //  The hero!    player = game.add.sprite(100, 300, 'ship');    player.anchor.setTo(0.5, 0.5);    game.physics.enable(player, Phaser.Physics.ARCADE);    //  And some controls to play the game with    cursors = game.input.keyboard.createCursorKeys();    fireButton = game.input.keyboard.addKey(Phaser.Keyboard.SPACEBAR);    game.input.keyboard.addKeyCapture([        Phaser.Keyboard.LEFT,        Phaser.Keyboard.RIGHT,        Phaser.Keyboard.UP,        Phaser.Keyboard.DOWN,        Phaser.Keyboard.SPACEBAR    ]);}function render() {}function update() {    //  Scroll the background - 1.1? Change later.    starfield.tilePosition.x -= 1.1;    // Changed from velocity to simple coord increment    if (cursors.up.isDown)    {        player.body.y -= 1.1 * playerSpeed;    } else if (cursors.down.isDown)    {        player.body.y += 1.1 * playerSpeed;    }    if (cursors.left.isDown)    {        player.body.x -= 1.1 * playerSpeed;    } else if (cursors.right.isDown)    {        player.body.x += 1.1 * playerSpeed;    }    //  Firing? - Something wrong with this and up-left    if (fireButton.isDown)    {        fireBullet();    }}// Handle player fire bullet - Not very optmizedvar bullet;function fireBullet () {    //  To avoid them being allowed to fire too fast we set a time limit    if (game.time.now > bulletTime)    {        //  Grab the first bullet we can from the pool        bullet = bulletsBeta.getFirstExists(false);        if (bullet)        {            //  And fire it            bullet.reset(player.x, player.y + 12);            bullet.body.velocity.x = 800;            bulletTime = game.time.now + 100;        }    }}

    Any help would be massively appreciated.


  11. Hello everyone,

    Fairly new to Phaser and have hit an initial 'bump' as it were. I'm attempting to simulate a feeling of z-depth on a tree in an isometric sort of style game, where in that if you walk around the back of the tree, the character appears behind it, but when you come round to the front, the character will then appear to be over the top of it (such as the players head and shoulders).


    So far I've looked in to setting the z-indexing on a group, and also so far have fathomed that the players y value in comparison to the trees y value will determine what the players z-depth is. I've yet to test this theory, but wanted to see if it could be achieved by easier means.


    Hope this makes sense, it's quite late, so my skills in finding an accurate explanation are faltering a bit...


    Thanks very much!


  • Create New...