PosA Sprite to PosB Sprite only working one way

  • Problem Description

    ____ A concise description of your problem here ____

    Going from SpriteA to SpriteB that is in the same X Position + the other way round

    Attach a Capx

    ____ Upload a Capx to this post ____

    Dropbox link - Capx

    Description of Capx

    ____ Concise description of what this CapX does ____

    Steps to Reproduce Bug

    • Step 1 on key pressed -> is overlapping PosA sprite -> compare PosA Sprite's x position with PosB Sprite's x Position
    • Step 2 if PosA sprite's X position is equal to PosB's -----> Set player sprite to PosB position
    • Step 3 etc. replicate it for the other way round

    Observed Result

    ____ What happens? ____

    goes to first instance of the same sprite

    Expected Result

    ____ What do you expect to happen? ____

    switching back and forth between SpriteA and SpriteB in the same X position.

    Affected Browsers

    • Chrome: (YES)
    • FireFox: (YES)
    • Internet Explorer: (YES)

    Operating System and Service Pack

    ____ Your operating system and service pack ____

    Windows 8.1 professional

    Construct 2 Version ID

    ____ Exact version ID of Construct 2 you're using ____

    Release 209 (64-bit/Steam)

  • This is not a bug. Construct 2 is interpreting the events the way it should. Here is what it's doing:

    It first checks to see if Sprite3 is overlapping the PosB and then moves Sprite 3 to PosA

    Then it checks to see if Sprite3 is overlapping PosA. Since it was just moved to PosA because of the previous event it is then moving back to PosB.

    You need to set it up like this:

    Keyboard On Down Arrow Pressed

    Sprite3 is overlapping PosB...

    Else

    Sprite3 is overlapping PosA...

    That way it won't move the Sprite3 from PosB to PosA and then back.

  • Just to reinforce what lohborn has said, here's the amended .capx:

    https://dl.dropboxusercontent.com/u/34306693/PosA%20to%20PosB-fixed.capx

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Just to reinforce what lohborn has said, here's the amended .capx:

    https://dl.dropboxusercontent.com/u/34306693/PosA%20to%20PosB-fixed.capx

    lohborn zenox98 well it works. i feel like this is the one instance written code would have been the better alternative to interpreting this better. :L either way thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)