refrencing question

For questions about using Classic.

Post » Tue Jul 12, 2011 7:16 am

Okay if I insert a For condition how do I refrence to that object
B
2
G
1
Posts: 24
Reputation: 498

Post » Tue Jul 12, 2011 8:56 am

What exactly do you mean? 'For' condition isn't object
Do you mean "for each object" loop?
B
2
S
2
G
2
Posts: 158
Reputation: 1,366

Post » Tue Jul 12, 2011 11:07 am

Yeah, if you do mean "for each object"
Then it automatically picks each object one at a time, and any actions referring to that objecttype in that event are automatically executed on the currently picked in that loop
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Tue Jul 12, 2011 2:51 pm

Oh I understand now I'm just new to the type of looping in construct sorry if it was to silly to ask.

One more question please

What's the best way to make a homing missile
I've tried storing a variable of the enemy but that didn't work out so well since I can only store strings or numbers in private variables and don't know how to convert that to a family type.

I thought I'd use the family type to find the closest object of that family and move towards it but I'm having a bit of trouble figuring out how to process objects of a family with a certain name
MuseFire2011-07-12 14:56:06
B
2
G
1
Posts: 24
Reputation: 498

Post » Tue Jul 12, 2011 3:09 pm

If you do
[code]+ "Family name": Pick closest to: Sprite.X, Sprite.Y
-> "Family name": - do something -[/code]
no matter how many objects you have in your family, it will always select only one sprite closest to Sprite.XY

Family works like a group of objects and can share same variables.
Let say you have 5 different sprites in "Family" and each of them have private variable "Health = 10"
[code]+ Sprite: On collision between Sprite and "Family"
-> Sprite: Subtract 1 from 'health'[/code]
It will only subtract 1 from collided object.
other 4 sprites will remain with value 10
shinkan2011-07-12 15:10:56
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Jul 12, 2011 3:12 pm

...and for homing missile it depends. You can give your sprite Bullet behavior and set it to
[code]+ System: Always (every tick)
-> Sprite_missile: Set angle towards Sprite_target[/code]



edit: couldn't edit last post:/shinkan2011-07-12 15:13:03
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Post » Tue Jul 12, 2011 3:20 pm

Okay I'm going to try this out now thaks for the help, I'm starting to like Constuct alot now
B
2
G
1
Posts: 24
Reputation: 498

Post » Tue Jul 12, 2011 5:27 pm

If you want to remember the same target and home on it even when others get closer you could do it like this

Make missle have a private variable called target, with a default of -1

For each missle,
------if target is equal to -1
-----------enemyfamily. - pick closest to missle.x,missle.y
------------------missle, set 'target' to enemyfamilt.uid

For each missle
------if target is not equal to -1
----------enemyfamily, pick by unique id missle('target')
-------------------missle(with bullet behavior). Set angle toward enemyfamily


This would make each missle target one enemy and stick with it till the end, though it'll be a bit trickier if you don't want two missles to ever target the same one
Spriter Dev
B
88
S
21
G
12
Posts: 3,240
Reputation: 16,486

Post » Tue Jul 12, 2011 5:47 pm

Thanks for the help it's really appreciated.


Just for intrest sake how do I refrence a family that has a space in it's name or should I just make a new family with a _ in it's name instead of spaces?
B
2
G
1
Posts: 24
Reputation: 498

Post » Tue Jul 12, 2011 6:04 pm

don't remember if families warks with spaces in between, i don't even remember if use spaces at all in CC ^^. I'm used to insert _ automatically :)
ImageImageImageImage
B
140
S
58
G
36
Posts: 2,547
Reputation: 31,170

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests