PosA Sprite to PosB Sprite only working one way

Bugs will be moved here once resolved.

Post » Wed Jul 08, 2015 6:41 am

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)
B
29
S
6
G
2
Posts: 232
Reputation: 2,893

Post » Wed Jul 08, 2015 3:46 pm

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.
B
6
S
1
Posts: 21
Reputation: 942

Post » Wed Jul 08, 2015 4:31 pm

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

https://dl.dropboxusercontent.com/u/34306693/PosA%20to%20PosB-fixed.capx
If your vision so exceeds your ability, then look to something closer.
Moderator
B
134
S
30
G
84
Posts: 5,379
Reputation: 58,440

Post » Wed Jul 08, 2015 4:45 pm

zenox98 wrote: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
B
29
S
6
G
2
Posts: 232
Reputation: 2,893


Return to Closed bugs

Who is online

Users browsing this forum: No registered users and 1 guest