• Content Count

  • Joined

  • Last visited

1 Follower

About rhennig

  • Rank
    Advanced Member

Recent Profile Visitors

1020 profile views
  1. Hi, no, I'm not using any plugins. It's just a simple test. To clarify, this is how the code runs with cordova on the browser (cordova run browser). Using this code to set the ground position: ground.create(totalwidth/2, totalheight, 'ground').setOrigin(0.5, 1); And this is the same code on the device. As you can see there is a blank space below the "ground".
  2. Hello! I'm having some troubles positioning objects on the screen of my mobile device using Cordova... I'm getting the screen height with: totalHeight=this.sys.game.config.height/window.devicePixelRatio; But when I try to put my object on the bottom of the screen with: ground.create(totalwidth/2, totalHeight, 'ground'); It works perfectly on the browser but on the mobile device it is not totally on the bottom (maybe someting like 80%~90% from the bottom), and I'm not getting why (I've tryed to change the setOrigin value but doesnt fixed the problem)... Is there something that I'm missing? Thanks in advance!
  3. Every time the weapon is fired the signal onFire is sended. You can just use it like: weapon.onFire.add(function(){ //do what you want });
  4. Hello guys, I've created an object that extends a Phaser Sprite object and I'm trying to put a keyboard listener on it. I'm doing it through (inside the object): game.input.keyboard.addCallbacks(this,function(key){...}); and this works fine for the first object, but, if I instantiate more objects just the last created object receive the keyboard input (seems like the last created overwrites the listener from the previous one). My objective is make all objects listen to the keyboard input, any tip? Thanks in advance!
  5. Ok, I have a tilemap as background and putting the click handler on the layer fixed my problem. Thanks!
  6. 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!
  7. Create: this.bk = this.add.tileSprite(0,0,this.game.world.width,this.game.world.height,'bkg2'); Change: this.bk.loadTexture('bkg');
  8. 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.
  9. 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() { } };
  10. Are you running a local web server?
  11. 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).
  12. Yep, my bad. I've edited to avoid confusion but declaring it 2 times was really nonsense... Thanks for pointing!
  13. maybe Dragonbones? (http://dragonbones.com)
  14. 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');