I referred to the Resource API documentation, decided to create an image with an alpha value and set it to a sprite with a transparent image.
However, the image is not transparent and now looks like Hard light effect.
Isn’t the fourth value in the stream an alpha value?
How can I create an image with an alpha value?
function init(self)
local size = go.get("#blank", "size")
self.width = size.x
self.height = size.y
self.buffer = buffer.create(self.width * self.height, {{name=hash("rgba"), type=buffer.VALUE_TYPE_UINT8, count=4}})
self.stream = buffer.get_stream(self.buffer, hash("rgba"))
for y = 0, self.height - 1 do
for x = 0, self.width - 1 do
local index = y * self.width * 4 + x * 4 + 1
if bit.bxor(bit.band(y, 1), bit.rshift(bit.band(x, 2), 1)) == 0 then
self.stream[index + 0] = 0xff
self.stream[index + 1] = 0x80
self.stream[index + 2] = 0x30
self.stream[index + 3] = 0x00
else
self.stream[index + 0] = 0x80
self.stream[index + 1] = 0x30
self.stream[index + 2] = 0xff
self.stream[index + 3] = 0x00
end
end
end
local resource_path = go.get("#blank", "texture0")
local header = {width=self.width, height=self.height, type=resource.TEXTURE_TYPE_2D, format=resource.TEXTURE_FORMAT_RGBA, num_mip_maps=1}
resource.set_texture(resource_path, header, self.buffer)
end