Complex arrays

Get help using Construct 2

Post » Tue Feb 28, 2012 3:41 pm

You could very well use only a single sprite with different animations.
On startup you select a random instance and set it to use the animation of your choice.
Capx for creating a random anim Sprite

Now what you want is to have sprites already spawnt along the layout apparently.
Commented capx for this
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 » Tue Feb 28, 2012 3:44 pm

Damn I've been Kyat ninja'd
[quote]//On the layout there are four hidden objects called (book,table,spoon,lamp) each of them has at least 10 frames, so I can't create only one object and then calling a random frame.[/quote]

You can... And you should!

Basically I would setup the layout this way:
A Sprite called 'item' in which you put your animation of book,table,spoon,lamp.
Name the animations properly.

Then if you want to call a random object
[code]System: Create item
item: set animation to tokenat( pool , floor( random( tokenCount(pool ,",") ) ), "," );[/code]

If you want to pick a specific object and play his animation
[code]item: is animation "spoon" is playing
-> item: start animation from current frame[/code]

Little remarque on the last one: even if the animation is stopped as long as you display a frame from a specific animation the "is animation playing" is true.

In short you can use the name of the animation as... naming as you implied I think.

Also, if you have many animation per object, you can still use the name as a prefix
spoon_idle, spoon_run (oh noes a running spoon /o/)
Yann2012-02-28 15:46:27
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 28, 2012 5:11 pm

@Yann, @Kyatric as usual thanks.

I see there's always a solution to my problems, next time I'll approach the problem with a different attitude.

Love
B
29
S
9
G
6
Posts: 525
Reputation: 8,294

Previous

Return to How do I....?

Who is online

Users browsing this forum: 99Instances2Go, Braus, supreme676 and 7 guests