how to say "all objects of type X"

Get help using Construct 2

Post » Sat Aug 18, 2012 10:52 am

If you say want 9 tiles in your game, you simply import the sprite for 1 tile, then clone it 8 times to make your grid.

However, if you want to do something like "Mouse->Cursor is over" you have to pick one of your 9 tiles - is there any way to say "any tile object"?

I could only add 1 in the designer, and spawn the other 8 in the event sheet, but this is a pain as I cant use the layout editor.nutmix2012-08-18 10:53:27
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Sat Aug 18, 2012 10:55 am

I think Ive found the answer - you cut and paste it, rather than clone. So easy when you know how!

Construct 2 is Amazing.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Sat Aug 18, 2012 11:04 am

Ok, thats not the answer - you cant address an individual instance then. I guess ill just have to have 9xCursor is Overs etc.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691

Post » Sat Aug 18, 2012 3:42 pm

[QUOTE=nutmix]
However, if you want to do something like "Mouse->Cursor is over" you have to pick one of your 9 tiles - is there any way to say "any tile object"?
[/QUOTE]
If you put all your tile objects in a family called Tiles, then you can do "Mouse: Cursor is over Tiles".

Or if you have 9 copies of one tile object, you could give them an instance variable called 'id' and set it to 1,2,3,4, etc. Then to pick a specific tile you can use 'tile: id = 3'.
B
54
S
28
G
18
Posts: 1,520
Reputation: 25,000

Post » Sat Aug 18, 2012 4:18 pm

You should still be able to address individual instances when using 9 instances (copy+paste or ctrl+drag instead of clone). What did you try? There's probably a way to fix it.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Sat Aug 18, 2012 6:32 pm

Indeed, it is possible to pick specific instances of an object type.
Check the how do I FAQ in the section "Picking/selecting instance(s)", there are already many elements listed with full discussions and examples on the subject as this is quite an important part of C2's basics.

You can also check the tutorials (for example this one or this other one which deal entirely or in part with picking).
New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 6,998
Reputation: 57,791

Post » Sat Aug 18, 2012 10:42 pm

Brilliant responses, and several options. In the end I went with making copies, rather than clones, and giving each one an ID instance variable as suggested, then using several for each loops. Ill try the UID option when get I more time.
B
15
S
5
G
2
Posts: 357
Reputation: 3,691


Return to How do I....?

Who is online

Users browsing this forum: bluemonkey, MarkThomas and 22 guests