[Fixed] Detect object at same X position?

Get help using Construct 2

Post » Sun Jul 21, 2013 9:59 pm

Hi,

I'm building a Infinite Jump like game. You have to jump up a tower. It'll be an improved version of my game Minimal Jump, which you can play here.

Each floor you have jump on is based on 2 platforms (called platform1 and platform2) with a gap of 160 pixels. I want to set x of a platform, which exits to a side 160 pixels from the other platform, depending on the direction the platform is moving.

Currently I do the following:

platform2 has an instance variable called partner_uid, which is set to the UID of the firstly created platform1. It looks like this:

[CODE]Local number cur_uid = 0
System: Create object platform1 at (xpos, ViewportTop("GameLayer")
System: set cur_uid to platform1.UID
System: Create object platform2 at (xpos+160, ViewportTop("GameLayer")
Platform2: Set partner_uid to cur_uid
[/CODE]

Now if platform1 vanishs to the right I'll want to set its position to platform2.x-960 (size of the platforms is 800 + 160 for the gap), so it can reenter from the left. The following is my code for this event:

[CODE]Platform1: X > 1200
System: Pick Platform2 where Platform2.partner_uid = Platform1.UID
    Action Platform1: Set X to Platform2.X-960
[/CODE]
I repeat this for X < -400 and vice versa for Platform2

Unfortunaly this doesn't work, the Platform just disappears and doesn't reenter.

Does anyone have a solution for this? Any help is appreciated.

Kindest regards,
Oliver

(Edit) PS: Oh, just if you wonder, why this works in Minimal Jump: I have a fixed layout height there (with a very small window) and could use the wrap behaviour. This doesn't work, if the floors are randomly generated.Hamrath2013-07-22 09:29:39
B
29
S
5
G
3
Posts: 14
Reputation: 3,163

Post » Mon Jul 22, 2013 9:30 am

Never mind. I missed some calculations. :-/
B
29
S
5
G
3
Posts: 14
Reputation: 3,163


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 22 guests