How do I Switch positions of two sprites

Get help using Construct 2

Post » Sun Jun 29, 2014 5:41 pm

Hello, here`s the thing:

I am creating a inventory system that is its own layout and I am storing object data such as armor etc. in to instance variables of the sprite. Item creation (transferring collected items from actual level via Web storage) is working fine and the correct values are transferred.

Inventory system works like this: you click object and then you click item slot and item moves to that slot. This also works fine.

My problem is this: I can`t figure out how to switch two instances of the same sprite in to each other's positions.
So i need to have it working like:
Click Item1 in inventory slot 2
Click item2(same sprite but different instance) in inventory slot 4
Item1 snaps to inventory slot 4 & item 2 snaps to inventory slot 2.

I tried to attach Capx but it kept saying that uploaded file is empty...

Thanks in advance
B
30
S
7
G
4
Posts: 31
Reputation: 4,913

Post » Sun Jun 29, 2014 6:01 pm

This thread had a similar situation, manipulating two instances of the same object.

viewtopic.php?f=146&t=108729&p=796618#p796618
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Sun Jun 29, 2014 6:46 pm

Thanks for your reply Blackhornet, double family thingy looks like it might work. I have to try it when I have little more time and little less tired brains. :D

Also here`s the Capx via Dropbox if someone wants to take a look.

https://dl.dropboxusercontent.com/u/137 ... ample.capx

Thanks
B
30
S
7
G
4
Posts: 31
Reputation: 4,913

Post » Mon Jun 30, 2014 1:51 am

Guys, store each object's position on an array (or global variables).Then you are good to go.
If you try to swap positions wont work because when you move one of them the other will be out of position already.
B
33
S
5
G
1
Posts: 163
Reputation: 2,693

Post » Tue Jul 01, 2014 2:49 pm

@Scofano, thanks for reply I see what you mean. However can you be little more specific how to achieve this, like how to pick instances vie events etc. I get the idea but I am having really hard time creating events for it.. Anyway thanks for your help
B
30
S
7
G
4
Posts: 31
Reputation: 4,913

Post » Tue Jul 01, 2014 3:34 pm

About arrays.
https://www.youtube.com/watch?v=oyqW_UJNux8
https://www.scirra.com/manual/108/array

Store each buttons position, then check the array for positions and make the switch.
B
33
S
5
G
1
Posts: 163
Reputation: 2,693

Post » Tue Jul 01, 2014 4:50 pm

You don't need an array, just two Temp variables.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Post » Tue Jul 01, 2014 4:53 pm

@blackhornet I think you are using the latest beta. I´m with the stable version, cannot open your file. I hope @virpoja can.
B
33
S
5
G
1
Posts: 163
Reputation: 2,693

Post » Tue Jul 01, 2014 5:02 pm

@Scofano just a simple trick, rename the file to .zip instead of .capx, open it and edit the .caproj file tag " <saved-with-version>17300</saved-with-version>" to ***000.
*** being whatever version you have
Please tag me with @caiorosisca if your post is refering to me :). I don't always follow the topics I answer.
B
11
S
4
G
1
Posts: 272
Reputation: 1,643

Post » Tue Jul 01, 2014 5:03 pm

The original was 174, I checked.
ImageImageImage
B
71
S
22
G
240
Posts: 3,734
Reputation: 133,994

Next

Return to How do I....?

Who is online

Users browsing this forum: AllanR, brunopalermo, farsen, ST314, TheRealDannyyy and 34 guests