How do I test the color in a specific location....

Get help using Construct 2

Post » Fri Sep 05, 2014 7:33 pm

Dear friends..i have a problem.... i don't know how to test the color in a specific location in a sprite....In other words...i want to test if in a sprite in a specific location is black or white...and then for example if the test is true make a sound...

Is it possible without plugin?? or bheaviour??? Can i do Normally?? Or there is a plugin out there???

Do you have a capx example???

Can you help Me Please?? Because my new app is based on this...

best regards,


Lestroso :oops:

http://www.fasasoftware.com
B
4
S
1
Posts: 73
Reputation: 504

Post » Fri Sep 05, 2014 8:30 pm

You mean something like this?

If so, It's quite simple. Create two frames on a sprite, make one black, one white. Check the position of your sprite, if it is where it should change colors, update the frame and trigger the sound through the "Media" Object.

Hope it helps.
You do not have the required permissions to view the files attached to this post.
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Fri Sep 05, 2014 10:23 pm

I modified the capx above :D

quadrantsmodded.capx
You do not have the required permissions to view the files attached to this post.
B
22
S
6
Posts: 244
Reputation: 2,700

Post » Sat Sep 06, 2014 3:50 am

Wow, amazing @Wisdoms! Go with his, much cooler!
B
13
S
2
G
1
Posts: 47
Reputation: 1,211

Post » Sat Sep 06, 2014 4:00 am

"how to test the color in a specific location in a sprite"

I thought he wanted to know the colour of a sprite (or part thereof) at a particular location.

The blending stuff is cool though..
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Sep 06, 2014 6:29 am

Dear friend thanks a lot ...but this is not for me the right solution.... i'm perhaps not well explain me...

I'll try again...if you can help me.....

Ok.. i need to test inside a sprite and/or image the color of a single pixel in a location always inside the sprite or image that i decide i, to know the value in number...255,255,255 or the value in color ...for example ..black or white ... etc..

Ok now it is clear... i'm sorry for the confusion....

any capx again?? Thanks a Lot in advance....

Lestroso :oops:

http://www.fasasoftware.com
B
4
S
1
Posts: 73
Reputation: 504

Post » Sat Sep 06, 2014 6:57 am

That's what I thought. I haven't done it, but maybe check the Canvas plugin
how-do-i-detect-color_t100725?
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Sat Sep 06, 2014 7:59 pm

dear codah,

can you help me please if you have already done it???? i will thank you so much.....have you a capx example to retrieve the color pixel in a specific location???

thanks again so much....


Best regards,

Lestroso :roll:

http://www.fasasoftware.com
B
4
S
1
Posts: 73
Reputation: 504

Post » Sun Sep 07, 2014 11:11 am

fasasoftware wrote:dear codah,

can you help me please if you have already done it???? i will thank you so much.....have you a capx example to retrieve the color pixel in a specific location???

thanks again so much....


Best regards,

Lestroso :roll:

http://www.fasasoftware.com


Sorry, I have not done it. Check the canvas plugin docs.
B
24
S
9
G
4
Posts: 1,646
Reputation: 6,596

Post » Mon Sep 08, 2014 7:24 pm

Many Thanks To Everybody!!!!

The Canvas-Plugin Creator wrote to me this detailed Instructions....AND Works Thery Fine!!!! Thanks Again...

Here The steps:

1
Create new project

2
Add mouse, text, and canvas objects

3
Give the canvas object an image and position it at 0,0

4
Go to the event editor and add a "every tick" condition.

5
Add the action: text-> set text to canvas.rgbaAt(int(mouse.x), int(mouse.y))

6
Run it and the text object will tell the color under the mouse on the canvas object.

Extra tidbits:
Int() is used since mouse.x can give values like 10.5 when window scaling is used and the value needs to be a whole number.

.rgbaAt uses x and y values relative to the top left of the canvas object. So if you moved the canvas object from 0,0 you'd have to change the expression to:
Canvas.rgbaAt(int(mouse.x-canvas.x), int(mouse.y-canvas.y))

Finally notice it only gets the color from the canvas' own texture. Use the drawing actions to change this texture.


Thanks A Lot Again....Cheers!! :lol:

Best Regards,

Lestroso

http://www.fasasoftware.com
B
4
S
1
Posts: 73
Reputation: 504

Next

Return to How do I....?

Who is online

Users browsing this forum: Artcadev, Google [Bot] and 21 guests