@fahlenring

Members
  • Content count

    34
  • Joined

  • Last visited

1 Follower

About @fahlenring

  • Rank
    Advanced Member

Recent Profile Visitors

272 profile views
  1. Why not? It's working for me...
  2. Create: this.bk = this.add.tileSprite(0,0,this.game.world.width,this.game.world.height,'bkg2'); Change: this.bk.loadTexture('bkg');
  3. 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.
  4. 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() { } };
  5. Are you running a local web server?
  6. 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).
  7. Yep, my bad. I've edited to avoid confusion but declaring it 2 times was really nonsense... Thanks for pointing!
  8. maybe Dragonbones? (http://dragonbones.com)
  9. 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');
  10. 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?
  11. 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?
  12. 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/
  13. Nice game! Really well done! Just for curiosity... are you making some income with the game on Kongregate? =X
  14. That is the reason for the "letsgo" variable on my example. At your code you're creating the first barrier after 1 second: var barrierDelay = 1000; If you dont verify if there is a barrier your update will test the colision before you have a barrier and that will result in your "cannot read property..." bug. You dont can test that if you dont have a barrier. So, if you set the "letsgo" variable to true after the first barrier (on the begining of your function): function createBarrier() { //ok, first barrier created, lets start! letsgo=true; ... } Your loop can start after your barrier is created: function update() { if(letsgo) scoreSystem(barrierGroup.getFirstAlive()); } avoiding this error.
  15. help

    You can add an extra parameter at: graphics.arc(0, 0, 500, game.math.degToRad(0), game.math.degToRad(360), false, 100); To increase the segments.