erich

Members
  • Content count

    73
  • Joined

  • Last visited

1 Follower

About erich

  • Rank
    Advanced Member

Contact Methods

  • Twitter
    webdesigneire
  1. Mobile screen touch controls

    Hi you can use the this.game.input.activePointer.isDown to use the screen as a button - I used it in one of my original games http://html5gamer.mobi/phaser2/oscar/ I made so you can press a mouse button on the screen (mobile use) or you can press the up cursor on a computer to jump sample code if (this.cursors.up.isDown || this.game.input.activePointer.isDown){ this.playerJump(); } else if (this.cursors.up.isUp || this.game.input.activePointer.isUp){ this.isJumping = false; } Hope that helps Eric
  2. Hi If anyone is interested I created a basic enemy path chase system. It may be of use to someone else trying to make one themselves or to create a better version of it. The basics of the sytem are quite simple (mainly 2 functions) - I created a map array and a group of enemies - In the update function I use the chaseMe() function for the enemies to use their "line of sight" to start the chase if the player isclose to the x and y on the stage - If the player escapes, there is a short timer that will move the enemy (moveMonster() function) in a random direction where it may "see" you again and start the chase again It is pretty basic - the demo is below, use cursor keys to move the player http://html5gamer.mobi/projects/6/ You can view the source code in the browser (ctrl + u) or download the full demo in the zip file attached Eric 6.zip
  3. collide using array

    I found my error, I had this.player.body.immovable set to true
  4. (posted in phaser 3 instead of the phaser forum by mistake) Hi I'm hoping someone can hep me, I'm trying to create basic map using an array with 2 different images, one is a wall, the other is a floor. I've created twp groups but when i use this.game.physics.arcade.collide(this.player, this.blocks, null, this.hitBlock, this); I've used the collide function before on other games with no issues - this is my first time using a 2d array but I can't see where the issue is happening code below : cursor controls to move link example :http://html5gamer.mobi/projects/6/ var GameHipster = GameHipster || {}; GameHipster.GameState = { init : function() { //keyboard controls this.cursors = this.game.input.keyboard.createCursorKeys(); this.upKey = this.game.input.keyboard.addKey(Phaser.Keyboard.W); this.downKey = this.game.input.keyboard.addKey(Phaser.Keyboard.S); this.leftKey = this.game.input.keyboard.addKey(Phaser.Keyboard.A); this.rightKey = this.game.input.keyboard.addKey(Phaser.Keyboard.D); this.actionKey = this.game.input.keyboard.addKey(Phaser.Keyboard.P); this.PLAYER_SPEED = 400; this.BULLET_SPEED = 500; this.score = 0; }, // end init preload : function() { },//end preload //executed after everything is loaded create: function() { blockdata = [ [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,1,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,0,0,0,0,0,0,0,0,0,0,0,0,0,1], [1,1,1,1,1,1,1,1,1,1,1,1,1,1,1], ]; this.blocks = this.add.group(); this.blocks.enableBody = true; this.floors = this.add.group(); this.floors.enableBody = true; var floor, block, i, j, col; var ROWS = blockdata.length; var COLS = blockdata[0].length; //console.log('R : ' + ROWS + ' C : ' + COLS); //console.log(blockdata[2][3]); for (i =0; i < COLS; i++) { for (j =0; j < ROWS; j++){ //col =1; col = (blockdata[j]); if (col ==0){ floor = this.floors.create( 1 + (i*64),1 +(j*64), 'block' + col); floor.anchor.setTo(0.5); } if (col ==1){ block = this.blocks.create( 1 + (i*64),1 +(j*64), 'block' + col); block.anchor.setTo(0.5); block.body.immovable =true; } } }; this.player = this.add.sprite(this.game.world.width / 2, this.game.world.height / 2, 'player'); this.player.anchor.setTo(0.5); this.player.scale.setTo(0.2); this.game.physics.arcade.enable(this.player); this.player.body.immovable = true; //ui this.uiBlocked = false; //text var style = {font : '20pt Arial', fill : '#fff'}; this.scoreLabel = this.add.text(10,10, 'SCORE : ', style); this.scoreText = this.add.text(130,10, '0', style); this.refreshStats(); }, //executed multiple times per second update: function() { this.player.body.velocity.x = 0; this.player.body.velocity.y = 0; this.game.physics.arcade.collide(this.player, this.blocks, null, this.hitBlock, this); this.keyboardControls(); }, // end update keyboardControls : function(){ //init keyboard controls if (this.cursors.left.isDown|| this.leftKey.isDown){ //this.player.angle += 5; this.player.body.velocity.x = -this.PLAYER_SPEED; } else if (this.cursors.right.isDown || this.rightKey.isDown){ //this.player.angle -= 5; this.player.body.velocity.x = this.PLAYER_SPEED; } if (this.cursors.up.isDown || this.upKey.isDown){ //thrust this.player.body.velocity.y = -this.PLAYER_SPEED; } if (this.cursors.down.isDown || this.downKey.isDown){ //thrust this.player.body.velocity.y = this.PLAYER_SPEED; } if (this.actionKey.isDown){ this.fireBullet(); } },// end function hitBlock : function(player, block){ console.log('hit'); }, endGame : function(player, enemy){ this.game.state.start('GameState'); }, refreshStats : function(){ this.scoreText.text = this.score; } }; Any help is appreciated Eric
  5. My first HTML5 game

    excellent work - well done !!
  6. [Phaser] Nature Basketball

    very nice game - well done
  7. The Adventures of the Pirate Robot

    very clever idea - well done
  8. Leaderboard with firebase and phaser

    was looking for the same - any good online examples ?
  9. The image is not displayed

    have a look at: http://phaser.io/examples/v2/basics/01-load-an-image should be : create: function() { game.add.sprite( 0, 0, 'flag' ); },
  10. Grumpy Cat's Worst Game Ever

    well done - thats really good ! Eric
  11. is it possible to tint a spritesheet

    cheers @scheffgames !
  12. Hi Quick question - is it possible to tint a spritesheet, I know you can use eg sprite.tint = 0xff00ff; but tint doesn't seem to work on an animation, is it possible or am I just better just photoshopping a new spritesheet? Thanks in advance Eric
  13. Animation or emitter?

    I find emitters very handy, this is a basic script snippet I modify as I see fit : var emitter = this.game.add.emitter(this.player.x, this.player.y, 15); emitter.makeParticles('star'); emitter.minParticleSpeed.setTo(-300, -300); emitter.maxParticleSpeed.setTo(300, 300); emitter.gravity = 0; emitter.start(true, 750, null, 15); this emitter is from my player sprite with a star png, you could easily modify this for your own needs hope it helps you Eric
  14. [Solved]Game stopped working

    works fine this end, player is walking on the ground and input is working fine - did you clear the cache and try again ?