How do I make a sprite instance that has an instance number?

Get help using Construct 2

Post » Thu Apr 09, 2015 11:35 am

I'm trying to chain instances of a sprite together similar to the way they're chained in the Example: Pin chain style

In the example, each instance of Blob has a number. However when I try to do this with my own layout, copies of my sprite don't have anyway to set the instance number under Instance Variables.

So I'm wondering, how do I enable the instance number option for a sprite?

Thanks!
B
9
S
2
Posts: 20
Reputation: 888

Post » Thu Apr 09, 2015 11:48 am

by clicking add/edit instance variable under instance variables in the object's properties-bar..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Apr 09, 2015 12:22 pm

LittleStain wrote:by clicking add/edit instance variable under instance variables in the object's properties-bar..


Yes that is the only option I can find, however that is not how it is done in the example.

In the example, the blob "number" value, auto increments every time you copy and paste an instance to the layout. So it seems to be an auto-generated instance variable. It only appears in the Properties but not in the Instance variables editor window.

I thought it may have something to do with Families but adding my sprite to a family didn't seem to make any difference.
B
9
S
2
Posts: 20
Reputation: 888

Post » Thu Apr 09, 2015 12:41 pm

You are talking about the UID?
That one increases automatically, but the instance variable "number", which is used in the event sheet to make the chain has to be changed manually.

from the manual:

inst.uid (read-only)
The instance's unique ID. Construct 2 issues the first instance a UID of 0 and increments by 1 for each new instance created. UIDs must never change through the life of an object.

inst.instance_vars[]
Array of instance variables. Each element is an ordinary javascript value corresponding to the current value of the instance variable at that index.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Apr 09, 2015 12:50 pm

Yes, thank you LittleStain!

I think I was getting the two confused especially as maybe there is glitch in the example so its not showing the instance variable "number" in the editor.

Thanks for helping me out!
B
9
S
2
Posts: 20
Reputation: 888

Post » Fri Apr 10, 2015 9:02 am

For a while I still couldn't get this to work until I noticed that the instance variable in the example belongs to the family BlobFamily not the Blob.
B
9
S
2
Posts: 20
Reputation: 888

Post » Fri Apr 10, 2015 11:34 pm

if blob is included in the family then he gets all families instance vars.
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
39
S
14
G
12
Posts: 617
Reputation: 9,297

Post » Sun Apr 12, 2015 7:28 am

saiyadjin wrote:if blob is included in the family then he gets all families instance vars.


Yes, thanks for clarifying that!
B
9
S
2
Posts: 20
Reputation: 888


Return to How do I....?

Who is online

Users browsing this forum: MAVERICK, tarek2 and 5 guests