Selecting by UID

Get help using Construct 2

Post » Sun Feb 28, 2016 9:03 am

Ah okay, in that case no file is required, it makes Sence now, thanks everyone for your input
B
12
S
2
G
1
Posts: 42
Reputation: 879

Post » Sun Feb 28, 2016 10:15 am

Here's a working example if you want anyway, with something to refer to to give you a clearer idea:
https://dl.dropboxusercontent.com/u/589 ... leIDs.capx
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Sun Feb 28, 2016 11:52 am

Relying on UID is not the best idea. The trick with instance variable works very well.

In the example @LaDestitute gave you actually check if the clicked object is the one you need. If you want to grab the instance directly from any place use the following:

System > Pick by comparison
first argument: spriteFont.instanceName
second argument: {the name you set manually}

Just be sure you have each instance name unique. Or it might be useful to have some of them named the same. For instance let's say you have a "credits" section in your game which is very long. You want to pin them to some drag&drop background sprite so user could scroll and see all the credits. Then you might set all the spritefonts instanceName value to "credits" and then pin them all with one event to the sprite.

So basically with the instanceName variable you can pick the distinct instance of an object or some group of them.
ImageImageImage
B
27
S
16
G
82
Posts: 1,029
Reputation: 45,777

Post » Sun Feb 28, 2016 11:56 am

It'll also work with keyboard controls, such as for a top-down ARPG and checking if the player is overlapping/near a certain chest or interactive object.
Zelda Gamekit (my project)



Example capxs:

Zelda-Style Inventory

Zelda Health

3-saveslot system

[url=https://www.dropbox.com/s/d4396pwak0oh7q6/ZeldaDialogueSystem.capx?dl=0]Zelda-like Dialogue[
B
51
S
24
G
30
Posts: 534
Reputation: 19,620

Post » Sun Feb 28, 2016 1:57 pm

Ah yes I'll change my statements to use the variable ID trick. Thanks all
B
12
S
2
G
1
Posts: 42
Reputation: 879

Previous

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 10 guests