How do I set an instance of same object to another iid/uid

Get help using Construct 2

Post » Thu Apr 20, 2017 2:43 pm

Hey there,

iam currently in a little hassle with this one:

I have two instances of the same type in my scene (its an endless runner) and now i want to reposition one object behind the other if theyre outside the screen. So far so good. But how do i place my object (iid 0) behind the same instance object (iid 1) ?

Could not find out currently how to set this up...

Thanks for your suggestion!
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Thu Apr 20, 2017 3:31 pm

@Congrats2u
Usual method for doing things where you need to pick two of the same type is to add a Family with just that object type in it.

For example, if you have an object type called Player, create a family called Family_Player with Player as a member.

So, your event could maybe be something like this:
Code: Select all
Player is on screen (inverted)
Pick Family_Player where Family_Player.X > Player.X
   -> Set Player.X to Family_Player.X - Player.Width
Find all the Construct 2 games that were on Steam Greenlight here
B
33
S
9
G
7
Posts: 451
Reputation: 6,782

Post » Thu Apr 20, 2017 6:59 pm

endless runner & reposition one object behind the other if theyre outside the screen

Endless means that those objects start outside the screen (on 1 side) and move off screen (on the other side) ?

Do they flip each pass ? Or is it a 1 time operation ?
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Mon Apr 24, 2017 10:25 am

@99Instances2Go

Thats right, they move from right to left, and if they leave the screen they will be repositionated on their old/start position.

The problem is: If i set it up like: if sprite is - 1024 it can happen that there is a small lag or delay and i get a gap between my background sprites. I got four background sprites layers witch are moving trough the sceen an will be repositioned again. And they will move faster and faster and this supports a larger offset, because i think if theyre outsite the screen they will not be replaced on the exact pixel (-1024 (maybe because of latency?))

I thougth i will set it up like: if youre outsite the screen take the current position of the other tiles get their width, and place the repositionated tile exact behind that.

I was hoping that this will avoid these gaps....
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Wed Apr 26, 2017 3:45 pm

Would be great if you got some ideas ;)
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Fri Apr 28, 2017 12:07 pm

Got to place them relative to the last one.
They are probaly the same instance.

So (pseudo) Using a Family containing 'Sprite'

Sprite < Sprite X < -1024
Family > position of right most
____ Sprite > set position ... x = Family.x + 1024 (i suppuse they are 1024 width)
B
33
S
18
G
28
Posts: 2,493
Reputation: 20,950

Post » Wed May 03, 2017 10:51 am

Hmmmm. i didn´t get it.
B
9
S
2
Posts: 147
Reputation: 1,041

Post » Wed May 03, 2017 12:03 pm

@Congrats2u

Here's a working example capx (r244)

It doesn't use Families but is fairly similar to what 99Instances2Go suggested
Find all the Construct 2 games that were on Steam Greenlight here
B
33
S
9
G
7
Posts: 451
Reputation: 6,782

Post » Thu May 04, 2017 7:26 am

@OddConfection

Just wow. This works perfectly! Thank you very much!
B
9
S
2
Posts: 147
Reputation: 1,041


Return to How do I....?

Who is online

Users browsing this forum: dand and 19 guests