affecting a large group of duplicate objects seperately

For questions about using Classic.

Post » Fri Jan 23, 2009 8:19 pm

I have a large grid of duplicate objects.

I'd like to have each one have seperate collision.

right now if I create a large grid of the same object, and then apply

if mouse is over object then change opacity to 50
if mouse is not over object then change opacity to 100

each object is changed as I mouse over each one, but I have to move the mouse away from the entire group for them to change back to 100 opacity, i'd like each object to change individually..

can anyone point me in the most sensible direction to achieve this?

thanks as always..
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Fri Jan 23, 2009 9:00 pm

If objects are too close together, then the condition remains true while mouse moves over objects, as it doesn't actually leave the object type yet.

But here is an unique property of each object instance: Unique ID - UID. See the code:

[code:nwff6iyo]+MouseKeyboard: Mouse is over Sprite
> System Set global variable 'Test' to Sprite.UID
> Sprite Set opacity to 50

+Sprite: Unique ID is NOT global('Test')
> Sprite Set opacity to 100
[/code:nwff6iyo]

Basically, whenever you hover mouse over an object, you change its opacity and store its UID, so it is exempt from the other event, which sets objects with different UID back to original opacity.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Fri Jan 23, 2009 9:49 pm

There's an even simpler way.

+ Always
-> Set object opacity to 100

+ Mouse is over Sprite
-> Set object opacity to 50

Events are read in top to bottom order, so they all have 100 opacity, except for the one under the mouse. "Mouse not over object" won't be true and won't run until the mouse isn't over any of the object, hence the problem.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,534

Post » Fri Jan 23, 2009 9:54 pm

thanks, that seems to only affect one at a time though, if a larger object that covers more than one object overlaps them, only one is affected..

my apologies if I came across as too specific..
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Fri Jan 23, 2009 10:14 pm

Sprite is over sprite
set opacity-

Sprite is not over sprite
set opacity+

using a sprite as pointer....
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Jan 23, 2009 10:31 pm

[quote="work3":2szhwnx2]thanks, that seems to only affect one at a time though, if a larger object that covers more than one object overlaps them, only one is affected..[/quote:2szhwnx2]
I don't understand. Do you have a .cap?
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,534

Post » Sat Jan 24, 2009 2:16 am

[quote="newt":3fgiak4o]Sprite is over sprite
set opacity-

Sprite is not over sprite
set opacity+

using a sprite as pointer....[/quote:3fgiak4o]

Yep, this would work pretty good. Just make a tiny sprite and always set it to mousex, mousey.
Moderator
B
5
S
2
G
6
Posts: 4,348
Reputation: 10,971

Post » Sat Jan 24, 2009 7:42 am

sorry ash, that works wonderfully, I was responding to the previous poster..

I think we may have posted our responses around the same moment :)

Thankyou all :)
B
4
S
2
G
5
Posts: 149
Reputation: 2,025

Post » Sat Jan 24, 2009 8:22 am

I learned a lesson, too! :D
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 2 guests