Anchor is not working?

Get help using Construct 2

Post » Wed Oct 04, 2017 10:49 am

Hi there!

I'm trying to "anchor" an object and I have never had any problems with that before. I'm working on a new game but this time when I play the game in the browser the object that is anchored is seen for a millisecond and then it disappears. Do you guys have any clue what the problem could be?

Thanks in advance,
Tomolo Games
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Post » Wed Oct 04, 2017 11:14 am

Hard to say without seeing the capx, but here are a few guesses:

Run the game in debug mode. Select the object and view its values; you should be able to see a dotted red outline on the layout when the object is selected:

If it no longer exists in the object list then an action somewhere in your code is destroying it.

If the red outline appears in the correct position and at the correct size then most likely it has either been set invisible, the opacity has been set to zero, or some other object is obscuring it; you can check the relevant instance values to determine if it's one of these options.

If the object exists in the object list and the (x,y) coordinates are correct but no red outline is shown then either the object or the layer scale/size may be set to zero.

If it appears to have moved and the (x,y) coordinates have changed then an action somewhere in your code is re-positioning it before anchoring.

If it appears to have moved but its (x,y) coordinates stay the same then it may be that you have the origin set to different positions on subsequent frames (if the sprite is animated).
B
22
S
9
G
4
Posts: 476
Reputation: 4,327

Post » Wed Oct 04, 2017 12:51 pm

First of all, a thousand thanks for replying. I really appreciate it!

It doesn't work even if a create a new project and start from scratch. I have just created a solid floor, a platform player and an object I want to anchor. Would you mind if I send you the file so you can take a look at it? If you have the time and energy to do so, you can contact me at [email protected]

Thanks again!
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Post » Wed Oct 04, 2017 1:29 pm

I can also add that when I delete the Anchor behavior the object is visible at all times.
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Post » Wed Oct 04, 2017 1:48 pm

Hi @Tibolli, sure, you can send the file to [email protected] or post a dropbox/google drive link here.
B
22
S
9
G
4
Posts: 476
Reputation: 4,327

Post » Wed Oct 04, 2017 1:55 pm

So what are your anchor settings?
Left edge = ?
Top edge = ?
Right edge = ?
Bottom edge = ?

Try setting Left edge=Window left, and Top edge=Window Top, others set to None.
Image

Did I help to fix a problem in your game? You can buy me a cup of coffee :)
B
17
S
9
G
71
Posts: 1,063
Reputation: 38,689

Post » Wed Oct 04, 2017 2:09 pm

I have sent you an e-mail now. Thanks again! :)
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Post » Wed Oct 04, 2017 2:10 pm

"Try setting Left edge=Window left, and Top edge=Window Top, others set to None."

Thank you for you reply but these are the settings I have already. But again, thank you :)
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Post » Wed Oct 04, 2017 2:19 pm

@Tibolli You need to position your anchored object at 0,0; If you run the game in debug mode and check the coordinates you'll see that it still exists and is positioned outside of the viewport, so when anchored it remains outside. Anchoring fixes an object to the specified settings relative to its initial position.
B
22
S
9
G
4
Posts: 476
Reputation: 4,327

Post » Wed Oct 04, 2017 2:47 pm

I love you, you're the best! Everything works great now :)
B
16
S
5
G
3
Posts: 61
Reputation: 2,684

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 7 guests