Dealing with unique Sprites.

For questions about using Classic.

Post » Tue Aug 11, 2009 9:59 pm

Hello, I'm currently working on a project where I'm developing a system to designate the attacker and the attack then using a formula determine using private variables how much damage is dealt. I have all the formulas and concepts done, I just have no idea how to implement it.

The problem is:
I need some way to take Private variables from one unique Sprite and Private Variable from another unique sprite, as well as the distance between the two. then using a formula, subtract the hp from the second one.

Both Sprites can change throughout the game so ideally I would like it all to taken care of by one event instead of having to write an event for each sprite(since there are going to be around 40 sprites used for this).

Thanks in advance for anyone who can solve my problem.
B
2
G
3
Posts: 16
Reputation: 882

Post » Tue Aug 11, 2009 10:07 pm



If you haven't gone through the Ghost Shooter tutorial yet you should, it covers this very topic :wink:
B
2
G
3
Posts: 27
Reputation: 904

Post » Tue Aug 11, 2009 11:26 pm

[quote="zero_rogue":c8zcbht6]Hello, I'm currently working on a project where I'm developing a system to designate the attacker and the attack then using a formula determine using private variables how much damage is dealt. I have all the formulas and concepts done, I just have no idea how to implement it.

The problem is:
I need some way to take Private variables from one unique Sprite and Private Variable from another unique sprite, as well as the distance between the two. then using a formula, subtract the hp from the second one.

Both Sprites can change throughout the game so ideally I would like it all to taken care of by one event instead of having to write an event for each sprite(since there are going to be around 40 sprites used for this).

Thanks in advance for anyone who can solve my problem.[/quote:c8zcbht6]

families
Also expressions
Check the wiki. Most of what your doing should be fairly easy to set up.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Tue Aug 11, 2009 11:44 pm

This will not work because I am looking to access the information form two unique sprites (private variables, and xy for one). Like I have said these sprites will be different each time I need to use this event, so I would like to have a system that would allow me to plug in the information from different sprites.

From what I've seen Families do things globally only, and each unique sprite has its own values, I was thinking of using families to designate Each sprite but I don't know how to do that. (and couldn't find anything on the wiki about it.)

let me say this again, In my project I will have about 40 sprites that will use this specific event in any combination.

In case I was not clear by Unique I mean an individual sprite(with a unique id), not just all the same sprites. From what I've seen Currently of construct It will get the unique id of any individual sprite you reference previously in the event, however in this case I need two different sprites that cannot be referenced. (not without making approx 1,500 events, 80 events if I need to reference one of them.)
B
2
G
3
Posts: 16
Reputation: 882

Post » Wed Aug 12, 2009 12:20 am

If you pick a family and change the pv all sprites in that family will have their pv changed.
If you pick an individual sprite, and change its pv the others in that family will stay the same.
Its all about the picking.
Btw you can have multiple families, you can have single sprites belong to multiple families, just like you can have multiple instances of the same object have different pv's, as well as multiple pv's.
Any way post a cap its probably easier to show you than to explain it.

edit:
Yep as well as what quasi said. You can pick with multiple conditions as well.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Aug 12, 2009 12:21 am



do this except make each sprite you want to be effected part of two families and change the objects in the action i pictured to the families red and blue. BOTH sprites NEED to be part of both families.

if your event was lets say: red collides with blue. (sprite2 hits sprite or vice versa)

it will pick the affected sprite in family blue and the effected sprite in family red. and choose the variables for damage associated to those sprites.

i dont understand what you meant by "From what I've seen Families do things globally only" families are just so that you can pick different objects of the same type (ie sprite) to meet the same conditions as other objects.
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Post » Wed Aug 12, 2009 4:48 am

Ok let me explain what I'm doing... I'm basically making an turn biased Rpg style game. So I have multiple units of the same type(ie multiple copies of the same sprite each with its own numbers) on the field. I'm also going to have a leveling system so the more kills a unit gets the more improved its skills will be.

What I need is a system of events that I can use for the attack of the units, so that i can click on the attacking unit, it grabs the attacking value, then click on the target,grab its defensive values, and the attack will be calculated then attack.

The forumula I use for attacking uses the
power, Accuracy, and weapon Range of the attacking units pv

defense of the target unit's pv

It also uses the Distance between the units.

It also uses a few global variables but those can be added easy...

I hope that clears things up on what I need. I think long story short I need something that can identify each individual sprite on screen then take the pv or other values from them. something like a Unique Id however I think UID's work only with each sprite.

about families:from what I understand Families only work on all sprites in the family, meaning they can only retrive/add values to all the sprites in the families.
B
2
G
3
Posts: 16
Reputation: 882

Post » Wed Aug 12, 2009 5:38 am

[url:2ky28ipy]http://dl.getdropbox.com/u/666516/familypicking.cap[/url:2ky28ipy]
If you hold mouse down and hover over a sprite that sprite will be destroyed.
If you click on a sprite all sprites will be destroyed.

You might want to check out the forum more, and try some other stuff before moving into rpg mode.
Image Image
B
161
S
48
G
90
Posts: 7,356
Reputation: 66,767

Post » Wed Aug 12, 2009 7:16 am

Ah-ha! I see where the train of thought got derailed. I thought any reference to a Family affects all sprites in it, however if you reference a single sprite in a family, much like they do with other sprites. It keep all other family references to that sprite. The wiki entry was really misleading in this..Thanks for the help.

This was the hardest hurdle to get over for me, I already have the movement added in(using a jerry rigged system to be overhauled with families now ^_^) as well as the know-how to complete the remaining tasks, you may not know this but I've been lurking the forum and wiki off/on for about 4-5 months now.

Ive already taken the plunge into this project and I'm not to be deterred. I'll drop the link to the project later down the road once I get a working model of it. :mrgreen:
B
2
G
3
Posts: 16
Reputation: 882

Post » Wed Aug 12, 2009 4:17 pm

[quote="QuaziGNRLnose":3l326m3v]
if your event was lets say: red collides with blue. (sprite2 hits sprite or vice versa)

it will pick the affected sprite in family blue and the affected sprite in family red. and choose the variables for damage associated to those sprites.[/quote:3l326m3v]
B
52
S
7
G
6
Posts: 1,945
Reputation: 7,610

Next

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 4 guests