valueerror Posted March 31, 2014 Share Posted March 31, 2014 here is the testcase: http://test.xapient.net/phaser/ALL/jumpthrough.html i made two versions of the checkOverlap() function.. in the second (commented out atm) i check in both ways but specially for the player velocity.. this leads to situations where the player velo is not enough anymore when "inside" the platform and bounces back really fast.. the first version somehow baffles me.. if the fist body is my player he always is moving UP.. therefore no further checks are needed.. i just let him through... BUT i honestly don't know the implications of that.. it's definitely not field tested the moving platforms would also work with a simple tween where i tween the velocity but with my custom function and some predefined attributes (bounds, velocity) that can also be configured in tiled so every platform already knows where to move, this is more precise.. @rich.. if this would be somehow suitable as an example feel free to copy/adapt/rewrite the code a small piece of the code: game.physics.p2.setPostBroadphaseCallback(checkOverlap1, this);function checkOverlap1(body1, body2) { if (body1.sprite.key === 'mario' && body2.sprite.key === 'platform'){ return false; } //for some reason if mario is body1 not body2 he is moving from below - thats all we need to find out to let him through return true;}function checkOverlap2(body1, body2) { if (body1.sprite.key === 'mario' && body1.velocity.y > 0 && body2.sprite.key === 'platform'|| body2.sprite.key === 'mario' && body2.velocity.y > 0 && body1.sprite.key === 'platform'){ return false; } // this checks if mario is jumping return true;} kass 1 Link to comment Share on other sites More sharing options...
JP91 Posted March 31, 2014 Share Posted March 31, 2014 hey the demo works very well good job. I'm checking collisions with the method that uses narrowphase and broadphase Link to comment Share on other sites More sharing options...
valueerror Posted April 1, 2014 Author Share Posted April 1, 2014 so do you think this approach is ok or am i using methods that never were built for this an there are other ways to do this? if so.. please let me know Link to comment Share on other sites More sharing options...
JP91 Posted April 1, 2014 Share Posted April 1, 2014 mmmm, in the demo with materials I add this game.add.tween(platformH.body.velocity).to({ x: '+100' }, 2000,Phaser.Easing.Back.Out).to({x:'-100'}, 2000,Phaser.Easing.Back.Out).yoyo().loop().start(); ,I think it works well Link to comment Share on other sites More sharing options...
valueerror Posted April 1, 2014 Author Share Posted April 1, 2014 i do the exact same thing in this example.. http://www.html5gamedevs.com/topic/1813-the-monthly-phaser-examples-contest/?p=31436 but the problem with this approach is that you can not easily define the distance the object will move.. distance is speed (tweened speed) * time so it is hard to determine where the object will turn... Link to comment Share on other sites More sharing options...
JP91 Posted April 2, 2014 Share Posted April 2, 2014 mmm calculate the position would not have much trouble,ehh about this function "checkOverlap1" I would say that using materials or collisionGroup, would avoid making such checks, but for now I'm trying to simulate some of the methods Arcade Physics,you've tried? Link to comment Share on other sites More sharing options...
valueerror Posted April 2, 2014 Author Share Posted April 2, 2014 how would you use materials or collision groups to make a platform where you can jump through from below but land on from above.. i don't see any way to accomplish this.. could you lighten me up a little? i am working with arcade physics too.. these platforms are easily made in arcade because you are allowed to define a custom collision handler every time you set up a new collision.. if this one returns true a collision will happen. game.physics.arcade.collide(player, platform, null, customHandler); Link to comment Share on other sites More sharing options...
JP91 Posted April 2, 2014 Share Posted April 2, 2014 jejej yeah, that I know ...ehh the arcade physics is very useful and practical to start with some basic physics is well, so I'm trying to do the same but in p2 physics.mmm.. for the type of platform do not need it, but let me and I try. Link to comment Share on other sites More sharing options...
JP91 Posted April 7, 2014 Share Posted April 7, 2014 here is the platform with materials.I think I could other methods such as distance and area but good used yet. https://googledrive.com/host/0B2Br6oKX-RFNRWI3NjFGcjJjQms/plataforma.html valueerror 1 Link to comment Share on other sites More sharing options...
Recommended Posts