Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Trying to scroll world in my platform game - breaks the hitTestPoint code

Community Beginner ,
Apr 29, 2014 Apr 29, 2014

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;


Visual imagery

TOPICS
ActionScript
367
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 29, 2014 Apr 29, 2014

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 29, 2014 Apr 29, 2014

HitTest has been done properly, because with out the scroll, hitTest works fine

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 29, 2014 Apr 29, 2014
               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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 30, 2014 Apr 30, 2014
LATEST

that's the problem. bottom is not added directly to container.

alternatively you can check a hittestobject between character and ground.bottom

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 29, 2014 Apr 29, 2014

I think I know the problem!

Will I need to use the localToGlobal function?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines