How do I spawn objects with different values of inst. vars.

Just started using Construct 2? Post your questions here

Post » Thu Aug 14, 2014 5:15 am

Hi folks,

I have a spawner that spawn objects every
Code: Select all
random(4,8)
second.

After spawning there is running a "rise" animation. After rising I set animation to "walk". But it seems that these setting isn't individual. :?

Code: Select all
Sprite -> On animation "Rise" finished -> SpriteBox - > Set rised to 1
.
Code: Select all
System -> SpriteBox.rised = 1 -> Sprite -> Set animation to "Walk" (play from beginning)


But after that setting "rise" did not appear anymore.

Someone got a hint or a tutorial abut spawning objects with random behavior/instance variables?

Thank in advance!
B
5
Posts: 8
Reputation: 237

Post » Thu Aug 14, 2014 5:35 am

got a .capx we can look at? I feel like this should work, unless I'm missing something..
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Aug 14, 2014 5:40 am

wait.. spritebox and sprite are two different things, eh?
not sure what you're up to there, but why not put the variable on the sprite instead of the spritebox?
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Aug 14, 2014 6:43 am

@spacedoubt might have it (mixing up instance variables from different objects). If not, try put a System:Once while true after

System -> SpriteBox.rised = 1 -> Sprite -> Set animation to "Walk" (play from beginning)

If it's true every tick, your animation will keep going back to the beginning and look like it's not doing anything.

A screenshot from the actual code would be more helpful.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Thu Aug 14, 2014 7:27 am

Sounds like a picking problem to me..

How is C2 supposed to know which spritebox should be affected by which sprite?
Easiest way would be to put sprite and corresponding spritebox in a container..
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 Aug 14, 2014 6:00 pm

Hi guys, thanks a lot so far.

Attached you will find a demo project which demonstrates what I mean.

As you can see with the first "Sprite" everything is ok. It just starts with an "Idle" animation. After finishing that Sprite.born become 1 and animation "Walk" and simulate control "left" starts. But all upcoming sprites now have Sprite.born = 1 instead of 0 what I think they should have when they have been created. :roll:

Thanks a lot!
You do not have the required permissions to view the files attached to this post.
B
5
Posts: 8
Reputation: 237

Post » Thu Aug 14, 2014 6:06 pm

Change Spite.born=1 to 'Pick by comparison': Sprite.born=1
ImageImageImage
B
71
S
21
G
231
Posts: 3,688
Reputation: 129,352

Post » Thu Aug 14, 2014 6:12 pm

Yep, that works fine! Thank you so much!!!
B
5
Posts: 8
Reputation: 237


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 0 guests