I'm making a 2d platform game and i'm not knowledgeable enough to know how to set up collisions with my character and platforms.
I basically want when fireboy1 hits basePlatform, fireboy1 to not be able to go any further
I have got this code so far i'm just struggling to understand what to put in the if statement itself. I have commented the part I am unsure about.
I'm not sure if this is the right way to go about it.
public function platformCollision():void
{
if (fireboy1.hitTestObject(basePlatform))
{
fireboy1.y = fireboy1.y = //current position on screen?
}
}
If you don't want
fireboy1
to go past thebasePlatform
, you should probably do something like:fireboy1.y = basePlatform.y - fireboy1.height
Please note that this all depends on both fireboy1 and basePlatform having top-left orientation.