megmut Posted October 23, 2015 Share Posted October 23, 2015 Not sure what to call the title.. sorry if it's misleading! I was helping someone in the chatroom and came up with this example to show them: http://phaser.io/sandbox/DqUvNpYR/play http://phaser.io/sandbox/DqUvNpYR Just out of curiosity, is there a better way of doing this? I'm sure there's a way it could check the 'platforms' x and y instead of using world x and y, but that still feels hacky. Thanks in advance Megmut Skeptron and jaru 2 Link to comment Share on other sites More sharing options...
chongdashu Posted October 23, 2015 Share Posted October 23, 2015 Just out of curiosity, is there a better way of doing this? I'm sure there's a way it could check the 'platforms' x and y instead of using world x and y, but that still feels hacky. Hmm, why would this feel hacky? I would think it would be better because it would then allow you to change, remove, or add platforms without having to change the code. Right now, if you delete a platform, you will need to update the magic values in the code that are based on the world position in order to make the wall sticking to look right. Link to comment Share on other sites More sharing options...
megmut Posted October 23, 2015 Author Share Posted October 23, 2015 but would it not be better to have the platfrom as an object.. a sprite, or a group of sprites.. and just call a stickTo method.. where by you stick to that object? Link to comment Share on other sites More sharing options...
jaru Posted October 23, 2015 Share Posted October 23, 2015 In addition to this. What changes to the code should be made, that the first and last box edges where rounded, making it smoother to the eye.Cheers,Jaru Link to comment Share on other sites More sharing options...
chongdashu Posted October 23, 2015 Share Posted October 23, 2015 but would it not be better to have the platfrom as an object.. a sprite, or a group of sprites.. and just call a stickTo method.. where by you stick to that object? Yup! I would assume that the stickTo method end up checking the platform's x/y values, as opposed to the world x/y values, which would be considered a less hacky approach. Maybe I'm misunderstanding your question -- I thought it was just a comparison between (i) using the world x/y positions versus (ii) using the platform's x/y positions. From your latest post, I believe you're talking about a design pattern as opposed something implementation-specific? Link to comment Share on other sites More sharing options...
drhayes Posted October 23, 2015 Share Posted October 23, 2015 I think if it works then you're more than halfway there. ( = You should probably use velocity instead of modifying the position directly; that way the sprite will participate in physics collisions. You should also not use +1; try +1*this.game.time.physicsElapsedMS. That will make the speed invariant under frame skips. chongdashu 1 Link to comment Share on other sites More sharing options...
Recommended Posts