nme and Graphics::Render

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

nme and Graphics::Render

Philippe Riou
Hi,

In nme, if I have a transparent bitmap over a shape, the HitTest returns
the id of the bitmap and not the shape's. It seems to act as if it
doesn't take the transparency in account. Is there a way to make the
HardwareContext::Hits() read alpha value when performing the test ?

I'm trying to bypass the problem by rendering the content of the
RenderTarget in a Texture but I suppose this is going to be slower.

Thanks,
Philippe

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: nme and Graphics::Render

Gamehaxe
Hi,
I'm not sure how flash handles this - does it take alpha into account?
Another possibility would be to disable the mouse for the bitmap,
or use a SimpleButton with a separate hit object.

Hugh

> Hi,
>
> In nme, if I have a transparent bitmap over a shape, the HitTest returns  
> the id of the bitmap and not the shape's. It seems to act as if it  
> doesn't take the transparency in account. Is there a way to make the  
> HardwareContext::Hits() read alpha value when performing the test ?
>
> I'm trying to bypass the problem by rendering the content of the  
> RenderTarget in a Texture but I suppose this is going to be slower.
>
> Thanks,
> Philippe

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: nme and Graphics::Render

singmajesty
Flash will return "true" for transparent pixels, so I think NME is doing  
the right thing here.

I think the only way to detect against transparent bitmaps in Flash is to  
use BitmapData.hitTest, so maybe that can be implemented


On Wed, 21 Sep 2011 07:48:08 -0700, Gamehaxe <[hidden email]> wrote:

> Hi,
> I'm not sure how flash handles this - does it take alpha into account?
> Another possibility would be to disable the mouse for the bitmap,
> or use a SimpleButton with a separate hit object.
>
> Hugh
>
>> Hi,
>>
>> In nme, if I have a transparent bitmap over a shape, the HitTest  
>> returns the id of the bitmap and not the shape's. It seems to act as if  
>> it doesn't take the transparency in account. Is there a way to make the  
>> HardwareContext::Hits() read alpha value when performing the test ?
>>
>> I'm trying to bypass the problem by rendering the content of the  
>> RenderTarget in a Texture but I suppose this is going to be slower.
>>
>> Thanks,
>> Philippe

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: nme and Graphics::Render

Philippe Riou
In reply to this post by Gamehaxe
Hi,

I haven't tested it yet but I think I found what was wrong. It may not come from the alpha, but from the mouseEnabled. Indeed, it is enabled by default for every displayobject. However, in flash, mouseEnabled can only be enabled if the displayobject is an interactiveObject.

The bitmap I'm hitting is not interactive but I believe it is hit tested because of this flag.

I'll keep you posted in a few minutes.

Philippe

Le 21/09/2011 16:48, Gamehaxe a écrit :
Hi,
I'm not sure how flash handles this - does it take alpha into account?
Another possibility would be to disable the mouse for the bitmap,
or use a SimpleButton with a separate hit object.

Hugh

Hi,

In nme, if I have a transparent bitmap over a shape, the HitTest returns the id of the bitmap and not the shape's. It seems to act as if it doesn't take the transparency in account. Is there a way to make the HardwareContext::Hits() read alpha value when performing the test ?

I'm trying to bypass the problem by rendering the content of the RenderTarget in a Texture but I suppose this is going to be slower.

Thanks,
Philippe


--

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: nme and Graphics::Render

Philippe Riou
Hi,

Ok that solved the problem for the previous case. Maybe you should set the mouseEnabled property to false in the displayobject constructor as it should be set by InteractiveObject.hx.

Now, I still have a similar behavior when sprites are rendered as bitmaps (DisplayObject::RenderBitmap). This happens when NonNormalBlendChild() == true in IsBitmapRender().

I have a scene that looks like this:
Lib.current.addChild(Sprite1);
Sprite1.addChild(Bitmap1);
Bitmap1.BlendMode = bmSubtract;

Basically, Sprite1 is just a container, it doesn't hold any graphics. Bitmap1 is a square moving on the screen.

Problem : The bitmap created from the Sprite1 doesn't match the Bitmap1 "square" shape. Instead it creates a rectangle that fits the whole screen and fills every pixel with alpha = 255. Therefore, what's behind can never be hit.

A way to solve the problem, would be to disable the mouseEnabled property of Sprite1. But what I don't understand is that Flash enables by default every interactiveObject and though, this particular case works even with mouseEnabled = true.

In the end, I have 2 questions:
1 - Is there a way to solve the problem without altering the mouseEnabled property ?
2 - Why does Sprite1 need to be rendered as bitmap because of its children blendmode ? (It doesn't display well if you don't do it)

Thanks a lot
Philippe

Le 21/09/2011 20:06, Philippe Riou a écrit :
Hi,

I haven't tested it yet but I think I found what was wrong. It may not come from the alpha, but from the mouseEnabled. Indeed, it is enabled by default for every displayobject. However, in flash, mouseEnabled can only be enabled if the displayobject is an interactiveObject.

The bitmap I'm hitting is not interactive but I believe it is hit tested because of this flag.

I'll keep you posted in a few minutes.

Philippe

Le 21/09/2011 16:48, Gamehaxe a écrit :
Hi,
I'm not sure how flash handles this - does it take alpha into account?
Another possibility would be to disable the mouse for the bitmap,
or use a SimpleButton with a separate hit object.

Hugh

Hi,

In nme, if I have a transparent bitmap over a shape, the HitTest returns the id of the bitmap and not the shape's. It seems to act as if it doesn't take the transparency in account. Is there a way to make the HardwareContext::Hits() read alpha value when performing the test ?

I'm trying to bypass the problem by rendering the content of the RenderTarget in a Texture but I suppose this is going to be slower.

Thanks,
Philippe


--



--

--
haXe - an open source web programming language
http://haxe.org