• Content count

  • Joined

  • Last visited

1 Follower

About @fahlenring

  • Rank
    Advanced Member

Recent Profile Visitors

365 profile views
  1. Ok, I have a tilemap as background and putting the click handler on the layer fixed my problem. Thanks!
  2. Hello! I'm having some troubles trying to change the priority of mouse clicks. First I set: this.input.onDown.add(function(){alert("world");}, this); To catch mouse clicks on my entire game window and this works fine. But sometimes I create sprites and I want them to have different mouse clicks events. For this I use: this.spritetest.events.onInputDown.add(function(){alert("sprite");}, this,100); My goal is to give priority to the sprite event function if clicked on a sprite and fire the "general function" if not. But the "general function" ever fires first! I tried to set the priority parameter as you can see on the second function but this doesn't seem to change anything in my case. Can someone points me how I can fix this? Thanks!
  3. Why not? It's working for me...
  4. Create: this.bk = this.add.tileSprite(0,0,this.game.world.width,this.game.world.height,'bkg2'); Change: this.bk.loadTexture('bkg');
  5. var ProjectName = ProjectName || {}; ProjectName.Game = function() { }; ProjectName.Game.prototype = { preload:function() { this.load.image('enemy2', 'assets/star.png'); this.load.image('enemy1', 'assets/dude.png'); }, create : function(){ this.enemies = this.add.group(); this.enemies.enableBody = true; for (var i = 0; i < 1; i++) { this.s = this.enemies.create(this.world.randomX, this.world.randomY, 'enemy1'); this.s.name = 'enemy1' + this.s; this.s.body.collideWorldBounds = true; this.s.body.bounce.setTo(0.1, 0.1); this.s.animations.add('walk', [0, 1,]); this.s.play('walk', 6, true); this.s.body.velocity.setTo(5 + Math.random() * 40, 5 + Math.random() * 40); } { this.f = this.enemies.create(this.world.randomX, this.world.randomY, 'enemy2'); this.f.name= 'enemy2' + this.f; this.f.body.collideWorldBounds = true; this.f.body.bounce.setTo(0.5, 0.5); this.f.animations.add('walk', [0, 1,]); this.f.play('walk', 6, true); this.f.body.velocity.setTo(150 + Math.random() * 40, 5 + Math.random() * 40); } }, update : function() { this.physics.arcade.overlap(this.f, this.s, this.enemyKill, null, this); }, enemyKill: function(enemy1,enemy2){ enemy1.kill(); } }; This is your code inside the Game.js state from the example above. With some minor changes to make it run.
  6. You need to put your entire code in the state not just a function, ok? (If you have a complex game you can split multiple stages in states if you want but for a small game there is no reason to do that...) Like this is an Index.html file pointing to state Main (Main.js). <html> <head> <title> States </title> <meta charset="utf-8"> <script type="text/javascript" src="js/phaser6.2.min.js"></script> <script type="text/javascript" src="js/Game.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <div align="center"> <div id="pgame"></div> </div> <script type="text/javascript" src="js/Main.js"></script> </body> </html> </script> </body> </html> This is the state Main(Main.js) loading state "Game" and running the state Game (Game.js) (there are other states comented just to show that you can load multiple states here if you want and you can call them later if you need through "ProjectName.game.state.start('State');") var ProjectName = ProjectName || {}; ProjectName.game= new Phaser.Game(800, 600, Phaser.AUTO, "pgame",null,false,false); /* ProjectName.game.state.add('Boot', ProjectName.Boot); ProjectName.game.state.add('Preload', ProjectName.Preload); ProjectName.game.state.add('MainMenu', ProjectName.MainMenu); ProjectName.game.state.add('GameOver', ProjectName.GameOver); ProjectName.game.state.add('Credits', ProjectName.Credits); */ ProjectName.game.state.add('Game', ProjectName.Game); ProjectName.game.state.start('Game'); This is "Game.js", here you can put your game: var ProjectName = ProjectName || {}; ProjectName.Game = function() { }; ProjectName.Game.prototype = { preload:function() { }, create : function() { }, update : function() { } };
  7. Are you running a local web server?
  8. Not sure if I understood your question but if not, try to explain again... States are used, normally, to change screens/scenes/actions in your game like: state 1 -> load stuffs state 2 -> show menu state 3 -> run game state 4 -> show credits state 5 -> show game over screen... I made a simple example here (you can inspect the code).
  9. Yep, my bad. I've edited to avoid confusion but declaring it 2 times was really nonsense... Thanks for pointing!
  10. maybe Dragonbones? (http://dragonbones.com)
  11. No sure if this is the best aproach but you can do something like (on create): this.bk = this.add.tileSprite(0,0,this.game.world.width,this.game.world.height,'bkg2'); And on update: if(condition to change background) this.bk.loadTexture('bkg');
  12. Sorry for asking again, but I'm really stucked on this problem... as the bug never occurs on the first run... is there not a way to make the game work at the same way after the state is restarted? some tip?
  13. ok, thanks for your answer, but why the game works fine on the first time and doesn't work after the game is restarted? (I've tryed to destroy/kill/clear the platform group on shutdown with no success) I'm not figuring out how I can simply make the game work at the same way after the state is restarted... some tip?
  14. Hello guys, I'm making a simple infinity runner and, sometimes, after the player falls in a hole and the game is restarted, platforms dont are created anymore. The group seems to dont restart correctly (Cannot read property 'body' of null) and I'm not sure how I can fix this. To test you can simply fall on the first hole and restart the game. Link is below and thanks for any help! http://funs2.com/funs2/games/pliniosrevenge/
  15. Nice game! Really well done! Just for curiosity... are you making some income with the game on Kongregate? =X