Heppell08 Posted January 17, 2014 Share Posted January 17, 2014 Pretty simple question. I've got a group called platforms like in the tutorial code. I've added a new wall to the group but want it at a 90 degree angle and be collidible. The group is collidible because if i remove the angle on my newly added wall i collide and walk on it.Its being added in with a .png image of a platform that i then scale down to nothing for invisibility in the game and the platform to be able to exists and collide too. var wall = platforms.create(2,game.world.height - 10,'ground'); wall.body.immovable = true; wall.x = 70; wall.scale.y = game.world.height; wall.scale.x = 0.001; wall.angle = 180;Its the same as in the basic platformer tutorial group set up for colliding. just not sure if it doesnt allow you to collide when walls are set at an angle. I did previously see a post on wall angles but couldn't find it on the forum.Any help appreciated.Thank Link to comment Share on other sites More sharing options...
XekeDeath Posted January 17, 2014 Share Posted January 17, 2014 I'm just trying to understand what you are doing here.Your code snippet rotates the sprite 180*, which means it is still the same width and height on the screen: tall and skinny...Your post says 90*, which would make it really wide and short. Why not make it in the position and the dimensions you want to begin with? Why do you need to rotate it at all? It is possible to set which sides you can and can't collide with on a sprite body. /** * Set the allowCollision properties to control which directions collision is processed for this Body. * For example allowCollision.up = false means it won't collide when the collision happened while moving up. * @property {object} allowCollision - An object containing allowed collision. */ this.allowCollision = { none: false, any: true, up: true, down: true, left: true, right: true };Side note: You can create invisible sprites by not including an image key, so you don't need to scale it down to 0.001 to make it invisible.var wall = platforms.create(2,game.world.height - 10); Link to comment Share on other sites More sharing options...
rich Posted January 17, 2014 Share Posted January 17, 2014 You can also do sprite.renderable = false. This will skip the render phaser for them, but still allow collision etc to function normally (which doesn't happen if you set visible to false). Link to comment Share on other sites More sharing options...
Heppell08 Posted January 17, 2014 Author Share Posted January 17, 2014 I posted code i was messing with but the reason i posted is because i dont want the sprite to walk past a specific point at the spawn of the game. It is originally supposed to be a vertical and invisible line that collides with the player.Sorry i got my test coding and forum coding confused. Thanks for the feedback. I'm still getting used to all this new coding since the shift from AS3. Very impressed and glad you guys are active on these forums Thank you Link to comment Share on other sites More sharing options...
Recommended Posts