rhennig

Members
  • Content count

    25
  • Joined

  • Last visited

About rhennig

  • Rank
    Member

Recent Profile Visitors

221 profile views
  1. 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?
  2. 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?
  3. 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/
  4. Nice game! Really well done! Just for curiosity... are you making some income with the game on Kongregate? =X
  5. 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.
  6. 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.
  7. Hello, as said before by GreatBigBore there are a lot of ways to do this and probably this is not the best one but this seems to fix your problem... ... var barrierGroup; var velocity = 250; var barrierDelay = 1000; var score=0; //create this var to verify if your first barrier is created var letsgo=false; ... function update() { //here you some test the first alive on your group, you dont need more... if(letsgo) scoreSystem(barrierGroup.getFirstAlive()); } ... function createBarrier() { //ok, first barrier created, lets start! letsgo=true; ... } As Claudiovc said your problem is that you are looping through all blocks of you're group, adding score for everyone. You dont need that and in this case, your first alive is a good one to help on your test...
  8. You really dont need to use "this." in this example, you can take it off... As the example runs inside the game object, the "this." keyword is used most of the times here to replace the "game." keyword, as you can see in comparisson to your code... As as we dont have more objects here there is no reason to use it, but I don't like to use global vars for some reason... Yes, you can replace the code: function(){alert("a melon!");this.melon.kill();} For a normal function(as you did in your code). This is a anonymous function and I some use it to avoid to write a new function for the test. For the cars spawn you probably will need randoms (to spawn in different positions) and groups(to make a group of cars and recycle them, if you need multiple cars on the screen). I think this examples can help you to start. http://phaser.io/examples/v2/misc/random-generators http://phaser.io/examples/v2/groups/recycling
  9. Hello, I tryed to simulate your problem with no succes, can you explain a bit more? http://funs2.com/funs2/games/ex/tint_ex/ Something similar? Or something else?
  10. http://funs2.com/funs2/games/ex/car_ex/ <html> <head> <title> Car Example </title> <meta charset="utf-8"> <meta name="landscape" content="user-scalable=0, initial-scale=1, minimum-scale=1, maximum-scale=1, width=device-width, minimal-ui=1"> <script type="text/javascript" src="js/phaser6.2.min.js"></script> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <div align="center"> <div id="pgame"></div> </div> <div id="wrongWay"></div> <script> var game= new Phaser.Game(this.window.innerWidth, this.window.innerHeight, Phaser.AUTO, "pgame",{preload: preload, create: create, update: update}); function preload() { this.load.image('road','as/road.jpg'); this.load.image('steen','as/steen.jpg'); this.load.image('steen1','as/steen.jpg'); this.load.image('auto','as/auto.jpg'); this.load.image('melon','as/melon.jpg'); this.load.image('turtle', 'as/turtle.jpg'); } function create() { this.physics.startSystem(Phaser.Physics.ARCADE); this.physics.arcade.gravity.y = 0; this.road = this.add.tileSprite(0,0,1250,700,'road'); this.physics.arcade.enable(this.road); this.steen = this.add.sprite(97,0,'steen'); this.steen.enableBody=true; this.physics.arcade.enable(this.steen); this.steen.body.immovable = true; this.steen.width = 92; this.steen.height = 700; this.steen.alpha = 1; //this.steen.body.allowGravity = false; this.steen1 = this.add.sprite(1078,0,'steen1'); this.steen1.enableBody=true; this.physics.arcade.enable(this.steen1); this.steen1.body.immovable = true; this.steen1.width = 92; this.steen1.height = 700; this.steen1.alpha = 1; this.turtle = this.add.sprite(546,400,'turtle'); this.turtle.enableBody=true; this.physics.arcade.enable(this.turtle); this.turtle.width = 162; this.turtle.height = 226; this.turtle.body.allowGravity = false; this.melon = this.add.sprite(830,100,'melon'); this.physics.arcade.enable(this.melon); this.melon.body.immovable = true; this.melon.anchor.setTo(0.5); this.melon.scale.setTo(0.3); this.auto = this.add.sprite(440,0,'auto'); this.physics.arcade.enable(this.auto); this.auto.anchor.setTo(0.5); this.auto.scale.setTo(0.3); this.auto.body.immovable = true; this.controls = { right: this.input.keyboard.addKey(Phaser.Keyboard.D), left: this.input.keyboard.addKey(Phaser.Keyboard.A), }; } function update() { this.road.tilePosition.y += 3; if (this.controls.left.isDown){ this.turtle.body.velocity.x = -200; } if (this.controls.right.isDown){ this.turtle.body.velocity.x = 200; } this.auto.body.velocity.y = 200; this.melon.body.velocity.y = 100; this.physics.arcade.collide(this.turtle,this.melon,function(){alert("a melon!");this.melon.kill();},null,this); this.physics.arcade.collide(this.turtle,this.auto,function(){alert("gameover!");this.state.restart();},null,this); this.physics.arcade.collide(this.steen,this.turtle); this.physics.arcade.collide(this.steen1,this.turtle); } </script> </body> </html>
  11. I'm not sure I understand your doupt, you're trying to drag your sprite? If yes try this: var game= new Phaser.Game(this.window.innerWidth, this.window.innerHeight, Phaser.AUTO, "pgame",{preload: preload, create: create, update: update}); function preload() { this.load.image('potato','potato.jpg'); } function create() { this.potato = this.add.tileSprite(0,0,50,50,'potato'); this.potato.inputEnabled = true; this.potato.input.enableDrag(); } function update() { }
  12. try to add gravity, like: physics.startSystem(Phaser.Physics.ARCADE); physics.arcade.gravity.y = 0; road = this.add.tileSprite(0,0,1250,700,'road'); physics.arcade.enable(road); steen = this.add.sprite(97,0,'steen'); steen.enableBody=true; physics.arcade.enable(steen); steen.body.immovable = true; steen.width = 92; steen.height = 700; steen.alpha = 1; ...
  13. Try to give them a body, like: steen.enableBody = true;
  14. Arcade is faster. If you need better performance (maybe for mobile, old computers or very complex games) stay with arcade (in good computers and/or in simple games you dont will feel any difference). But, arcade works only with rectangles so, if you need to collide with balls or something complexer you possible will dont have a good effect with arcade. I have a simple game made with P2JS and an older version made with arcade, you can see the difference between the ball collision with the basket. P2JS http://funs2.com/funs2/games/freethrow/ Arcade http://funs2.com/funs2/games/freethrowarcade/ I changed my P2JS code to make it have a similar effect as moveToPointer() example (http://phaser.io/examples/v2/arcade-physics/move-to-pointer). You can see it running here (http://funs2.com/funs2/games/pointer_example/). create : function() { this.canmove=false; this.baskball = this.game.add.sprite(this.game.world.centerX,this.game.world.centerY+(this.game.world.centerY/2),'ball'); this.game.physics.startSystem(Phaser.Physics.P2JS); this.game.physics.p2.gravity.y = 0; this.game.physics.p2.enable(this.baskball); this.baskball.body.setCircle(30); this.baskball.anchor.setTo(0.5, 0.5); this.baskball.body.moves = false; this.baskball.body.allowGravity = false; this.baskball.body.static = true; this.input.onDown.add(this.move, this); }, move : function() { this.baskball.body.velocity.x=this.game.input.activePointer.worldX-this.baskball.x; this.baskball.body.velocity.y=this.game.input.activePointer.worldY-this.baskball.y; this.canmove = true; }, update : function() { if (this.canmove == true) { this.baskball.x = this.game.input.activePointer.worldX; this.baskball.y = this.game.input.activePointer.worldY; } }
  15. Congratulation! Really nice game! What you're using for the advertising? I'm impressed by the performance too, really good. Are you using crosswalk or cocoon?