Access Sprite's RGBA Pixel Values

Discussion and feedback on Construct 2

Post » Sun Jun 09, 2013 1:09 am

Hi,

I want to be able to use the alpha channel of my background sprite to hold height data. Is there a way to get access to the RGBA of a pixel in a sprite for use in an Action?

Thanks
B
3
Posts: 3
Reputation: 181

Post » Sun Jun 09, 2013 1:25 am

You can't access its RGBA data directly, but you can use its height variable, or add an instance variable to the background to store that kind of data.
B
21
S
8
G
5
Posts: 89
Reputation: 6,017

Post » Sun Jun 09, 2013 1:30 am

Thanks for the reply. However, if I understand you correctly, that will not help me. I basically want a heightmap (2d array) for my background image, meaning each pixel will have a value 0-255 for its height and that I can access.
B
3
Posts: 3
Reputation: 181

Post » Sun Jun 09, 2013 5:23 am

So you want to create a height-map then? Such as the ones used for mapping topography?

You will probably have to create a javascript plugin to do something like that without having tons of sprites. Try asking for help over in the plugins section.
B
21
S
8
G
5
Posts: 89
Reputation: 6,017

Post » Sun Jun 09, 2013 10:50 am

You could use the Canvas plugin
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Sun Jun 09, 2013 1:20 pm

Or use the Array object?
Scirra Founder
B
386
S
229
G
87
Posts: 24,207
Reputation: 191,682

Post » Sun Jun 09, 2013 2:33 pm

Thanks for the replies all.

It seems some kind of plugin is the way to go.

An array won't help me because the heightmap will be created by the artist who creates the background image and then I'm back to the same problem of trying to access a image's RGBA values.
B
3
Posts: 3
Reputation: 181

Post » Sun Jun 09, 2013 4:00 pm

The use of an array would require some effort before hand. Like making an editor, and exporting a json file to be used as your heightmap.

Aside from that the reason there's not much there for per pixel operations is because it would be way too slow to use on any image of any largish size.
Image ImageImage
B
167
S
50
G
160
Posts: 8,170
Reputation: 103,436

Post » Sun Jun 09, 2013 7:30 pm

B
91
S
31
G
99
Posts: 5,193
Reputation: 65,672


Return to Construct 2 General

Who is online

Users browsing this forum: strevor73 and 9 guests