daniel0514 Posted May 21, 2015 Share Posted May 21, 2015 hi, I'm trying to make a frogger-like game and I want the player to go on top of some logs, to cross to the other side. (see images) the problem is, I haven't been able to achieve it. If I set the player to collide with the logs, the player won't go over it (see image). If i set it to overlap, the player just pass through the logs. What is the best way to make the player go over the logs, move with them like in the original frogger game, and get safe to the other side? Link to comment Share on other sites More sharing options...
phuurup Posted May 21, 2015 Share Posted May 21, 2015 Post the code! it's probably something else in combination to the overlap/collide issue you're having. Link to comment Share on other sites More sharing options...
daniel0514 Posted May 22, 2015 Author Share Posted May 22, 2015 i just have thisgame.physics.arcade.collide(this.player, this.logs, this.playerOverLog, null, this);the this.playerOverLogs function isn't doing anything at the moment, I believe it isn't even necessary, I just want the player to stand over the logs so it can cross to the other side. this is the code for the logsthis.logs = game.add.group();this.logs.enableBody = true;this.logs.physicsBodyType = Phaser.Physics.ARCADE;this.logs.createMultiple(4, 'log');this.logs.setAll('anchor.x', 0.5);this.logs.setAll('anchor.y', 0.5);this.logs.setAll('outOfBoundsKill', true);this.logs.setAll('checkWorldBounds', true);this.logs.setAll('body.immovable', true); Link to comment Share on other sites More sharing options...
Code Looper Posted May 22, 2015 Share Posted May 22, 2015 Can you set to only collide with the water, when not over the logs ?There must be a Phaser Frogger example online somewhere Link to comment Share on other sites More sharing options...
Skeptron Posted May 22, 2015 Share Posted May 22, 2015 I think you want the character to go though the logs (otherwise he couldn't reach the other side), so why not go with overlap and set his new vX speed when overlapping on a log, so that he moves as fast as the log he is on? Link to comment Share on other sites More sharing options...
ForgeableSum Posted May 22, 2015 Share Posted May 22, 2015 You want to use overlap:Typically, you'd use overlap for situations where you want to detect the meeting of two objects and do something, such as a player picking up a coin. Collide on the other hand would be used for situations such as bouncing off the head of an enemy, standing on a platform or a ball hitting a paddle - you want there to be a physical effect from the meeting of the two objects as well as (optionally) detecting the event.What I would do is, on overlap run a callback which sets the character to be a child of the overlapping log. That way, it will move along with the log as it tweens back and forth. You should still be able to move the character while the log is tweening, only its x/y position will be relative to the log instead of relative to the game world, which is what you want. When the character moves from one log to another, set it as a child to the new log on the overlap callback. Make sure your overlap callback is only running once, upon entry of the new log, otherwise you'll have two callbacks fighting to keep the character as a child to their respective logs. Link to comment Share on other sites More sharing options...
Recommended Posts