Copy link to clipboard
Copied
Hello As3 wizards
I'm making a game and my current code muddles up my collision.
container = new Sprite();
addChild(container);
container.addChild(ground);
container.addChild(character);
container.x = -character.x + stage.stageWidth / 2;
Copy link to clipboard
Copied
if your hittest is done correctly (ie, checking a hit between ground and character) there shouldn't be a problem because of changes to their parent's (container) x property.
Copy link to clipboard
Copied
HitTest has been done properly, because with out the scroll, hitTest works fine
Copy link to clipboard
Copied
if (ground.bottom.hitTestPoint(character.x + 13, character.y, true || ground.bottom.hitTestPoint(character.x - 13, character.y, true))) { while (ground.bottom.hitTestPoint(character.x + 13, character.y, true || ground.bottom.hitTestPoint(character.x - 13, character.y, true))) { character.incrementUp(); if (ground.bottom.hitTestPoint(character.x + 13, character.y, true || ground.bottom.hitTestPoint(character.x - 13, character.y, true))) { } else{ character.keepOnGround(); } } } }
P.S - thank you for taking your time, I noticed you're one of the top contributors in helping people, so thanks for the input.
EDIT:
I've posted this as a question on Stack Over flow, so if anyone does has answer, feel free to answer here too, since there is a bounty of 50 rep points.
http://stackoverflow.com/questions/23096320/getting-the-stage-to-follow-the-players-y-axis-flash-as3
Thank you.
Copy link to clipboard
Copied
that's the problem. bottom is not added directly to container.
alternatively you can check a hittestobject between character and ground.bottom
Copy link to clipboard
Copied
I think I know the problem!
Will I need to use the localToGlobal function?
Find more inspiration, events, and resources on the new Adobe Community
Explore Now