How do I display sprite?

Get help using Construct 2

Post » Tue Apr 25, 2017 3:43 am

Okay, I got this SPRITE FAMILY and randomly SYSTEM CREATES sprites from a certain family.
What I am to achieve is this?

FAMILY 1 > CHAIR, TABLE, BOOK
FAMILY 2> BLUE, BIG, NICE

Basically SYSTEM RANDOMLY CREATES A COMBINATION FROM BOTH FAMILIES EG.:

BLUE CHAIR

WHEN BLUE CHAIR IS CREATED IT FALLS DOWN ACROSS SCREEN TILL IT COLLIDES WITH A SOLID THEN I SET MAX SPEED TO ZERO AND THE WORDS STAY THERE.

I would like to display a sprite (I already have it) that corresponds to BLUE CHAIR, FOR EXAMPLE.

So, SYSTEM CREATES BIG CHAIR I want to display BIG CHAIR. I can't seem to find a way to do that. Tried OVERLAPPING AN INVISIBLE SOLID, COLLIDING WITH A VISIBLE SOLID. I am bummed out.

HELP!
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Tue Apr 25, 2017 4:04 am

@kiko2015 it hard to understand how your game works at all (or how it should).
As far i understand, you want to determin which random sprite combination was created?
You can set a family instance variable (e.g. 'type') and countnumber each object of the family (1=chair, 2=table, 3=book, ...) and check this variable/constant.

Better post your project (capx) to understand your question....
Image Image Image
B
43
S
22
G
15
Posts: 379
Reputation: 12,254

Post » Tue Apr 25, 2017 4:58 am

mercuryus wrote:@kiko2015 it hard to understand how your game works at all (or how it should).
As far i understand, you want to determin which random sprite combination was created?
You can set a family instance variable (e.g. 'type') and countnumber each object of the family (1=chair, 2=table, 3=book, ...) and check this variable/constant.

Better post your project (capx) to understand your question....



<a href="http://geocities.ws/alvoradaespirita/test/test.capx">capx</a>
B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Tue Apr 25, 2017 4:58 am

B
19
S
4
G
2
Posts: 97
Reputation: 2,244

Post » Tue Apr 25, 2017 3:39 pm

ok i see.

as mentioned add a family instance variable to each family
- the instance variable for CHAIR='chair', HOUSE='house', ...
- the instance variable for BLUE=1, BIG=2, ...

To reduce the code you can do the following:

Create a new sprite containing all corresponding sprites (combinations) you want to show - grouped (separate animation) by NOUN and frameindexed by ADJ.
Name the animations by this NOUNs (CHAIR, ...) [with the first animation frame is the BLUE CHAIR, the second the BIG CHAR, ...]
The ADJ instance variables have to correspone with the frameindex of each animation.

Once the resulting combination is fix (all falling sprites are known), you know the instance variables of NOUN and ADJ (e.g. 'CHAIR', 1 (for blue))
Then you create the representing sprite and set it's animation [NOUN-instancevariable = 'CHAIR'] and it's frame is [ADJ-instance variable = 1].

I hope you understand the way it works...
Image Image Image
B
43
S
22
G
15
Posts: 379
Reputation: 12,254

Post » Tue Apr 25, 2017 4:31 pm

mercuryus wrote:ok i see.

as mentioned add a family instance variable to each family
- the instance variable for CHAIR='chair', HOUSE='house', ...
- the instance variable for BLUE=1, BIG=2, ...

To reduce the code you can do the following:

Create a new sprite containing all corresponding sprites (combinations) you want to show - grouped (separate animation) by NOUN and frameindexed by ADJ.
Name the animations by this NOUNs (CHAIR, ...) [with the first animation frame is the BLUE CHAIR, the second the BIG CHAR, ...]
The ADJ instance variables have to correspone with the frameindex of each animation.

Once the resulting combination is fix (all falling sprites are known), you know the instance variables of NOUN and ADJ (e.g. 'CHAIR', 1 (for blue))
Then you create the representing sprite and set it's animation [NOUN-instancevariable = 'CHAIR'] and it's frame is [ADJ-instance variable = 1].

I hope you understand the way it works...


Thank you! :)
B
19
S
4
G
2
Posts: 97
Reputation: 2,244


Return to How do I....?

Who is online

Users browsing this forum: Armench, brunopalermo, dand, TRMG and 28 guests