How do I make an object match position?

Get help using Construct 2

Post » Sun Sep 14, 2014 11:14 pm

AnD4D wrote:Thanks a lot! I appreciate the help, but I do not believe this method will work.

My game has 4 ships that I need to do this with, and all are already part of a family. I have tried to alter your code to allow a second sprite to be linked in via the same family, but it does not work.

I will go with your initial advice, and just use separate objects. I was trying to avoid this, as my debugger is slowly turning into a nightmare, filled with objects. Sadly, groups do not transition over, so I need to scroll through dozens of objects just to find the one I'm looking for!

I greatly appreciate your help though!


Did you try the last uploaded version? It has 4 sprites. And just create another family for the picking purpose. But yeah.. unless you're going to save heaps of memory.. use separate object types.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sun Sep 14, 2014 11:21 pm

Yeah, figured I'd need a new family. I currently have 21 and counting (very large game), so I'm trying to keep it down. Oh well!

Thanks so much for the help!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Post » Sun Sep 14, 2014 11:23 pm

AnD4D wrote:Yeah, figured I'd need a new family. I currently have 21 and counting (very large game), so I'm trying to keep it down. Oh well!

Thanks so much for the help!


No worries. And yea you're right, it won't work.. easily
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 15, 2014 12:08 am

@AnD4D
Are the objects created and destroyed at runtime?

You could do this if the first 4 instances are controllable and the last 4 are ghost.

Sprite Boolean "ghost" is set
--- sprite set x to sprite(sprite.iid-4).x+400

Or if you just want each instance with ghost set to be at an offset you could do

Global otherx=0

Repeat 4 times
---Sprite is ghost
---pick sprite instance loopindex
------set otherx to sprite.x
---sprite is not ghost
---pick sprite instance loopindex
------sprite set x to otherx+400

Of course with that example there are 8 instances.
B
91
S
31
G
103
Posts: 5,236
Reputation: 67,758

Post » Mon Sep 15, 2014 11:32 am

@R0J0hound - Ahh, this "set x to sprite(sprite.iid-4).x+400" is what I've been looking for!

Thanks!
@bearboxmedia
www.bearboxmedia.com

Nintendo Wii U Developer using Construct 2
B
79
S
12
G
7
Posts: 961
Reputation: 10,717

Previous

Return to How do I....?

Who is online

Users browsing this forum: amkp, sublimate and 10 guests