Problem with node.mask = null

43 views
Skip to first unread message

Luke Tramps

unread,
Jan 14, 2016, 3:24:32 PM1/14/16
to Genome2D
Basicly I'm doing this:

gsprite.node.mask = gshape.node;

And I wanted to render gshape normaly, when its not used as a mask anymore.


So I tried to

gsprite.node.mask = null;

but got a null exeption in node.render()


Also if

gsprite.dispose()

Then the node (of the gshape) does not display with texture.


I wasn't able to test it with the new beta of genome2d because I get a error on startup.


However, when I do manually

gshape.node.g2d_usedAsMask = 0;

then it works.


Build c8246234d8631dcba680df86f3507402
Version 1.1
Date 2015-05-10 14:29:03

Luke Tramps

unread,
Jan 14, 2016, 3:40:29 PM1/14/16
to Genome2D
Ps. Im working with flash target, the error on startup happened only with the beta swc which I've downloaded today. Could be IDE related, flashdevelop :/

sHTiF

unread,
Jan 17, 2016, 5:25:28 AM1/17/16
to Genome2D
What kind of error does the beta throw, we got some problems with using Genome2D haxe swcs with Flex but thats about all, so if you are using it with standard Adobe AIR SDK it should work. I use FlashDevelop myself for some projects.

Also can you send a simple example with the shape masking in question?

Luke Tramps

unread,
Jan 18, 2016, 1:15:16 PM1/18/16
to Genome2D

OK, I found a solution and I wrote a protocol of what I was doing to find out. Maybe it helps someone.

The problem was, that I used a haxe swc library that I wrote some time ago. It is not compatible with the acutal g2d build, probably I used a different version of haxe for it.

Setup:
Win7
FlashDevelop 5.0.2.2
AIR Desktop Project with
AIR 20 (nothing flex involved)

** Before I found the solution I wrote this

If I'm working with the g2d beta build, that I mentioned above, it's all ok.

But I changed fd to use the newest g2d beta and got

[Fault] exception, information=TypeError: Error #1034: Type Coercion failed: cannot convert haxe.ds::StringMap@62ad4c1 to haxe.IMap.

then I replaced the linkage back to the old beta, that I described in the beginning of the thread and got 

[Fault] exception, information=ReferenceError: Error #1069: Property iterator not found on haxe.ds.StringMap and there is no default value.

So I change back to the newest build and like before I get

[Fault] exception, information=ReferenceError: Error #1069: Property iterator not found on haxe.ds.StringMap and there is no default value.

To me theese look like haxe like problems, as they occure if you dont haxe.initSWC(mc). Compiler strict mode and warnings where off, all the time.

The problem only occurs when I use the newest g2d, but it freaking stays/mutates from that point on, even if I unlink the new beta and use the one I've used before. So I assume it must be something with the IDE, while project->clean project does not cahnge a thing, neither did a restart of flashdevelop.

I restart my computer (its a 2 days old windows7 and dev enviroment installment), having the old beta linked in my project. Compile and ...

Fault] exception, information=ReferenceError: Error #1069: Property iterator not found on haxe.ds.StringMap and there is no default value.

Again, this is the g2d build that worked for me, before I touched the new one. So, I backup this curiosity and reset the branch via git, to the point before I used the new g2d swc. It's all ok again.

If you want me to dig into that and make tests, I'll do it - but this can hardly be related to your work, from what I can see.

** I was writing this while performing theese tests, at this point it came to my mind that there is another haxe compiled library in the project. 

So I remove the library, try both g2d builds and everything works. 

Damn.

Luke Tramps

unread,
Jan 18, 2016, 1:18:31 PM1/18/16
to Genome2D
// My internet sucks theese days and im not sure if the message to you was sent, so I post the masking bug here to be sure.

// Error on unmasking
package tests.genome 
{
import com.genome2d.components.renderable.GShape;
import com.genome2d.context.GContextConfig;
import com.genome2d.Genome2D;
import com.genome2d.node.GNode;
import com.genome2d.textures.GTexture;
import com.genome2d.textures.GTextureManager;
import flash.display.BitmapData;
import flash.display.MovieClip;
import flash.events.MouseEvent;
/**
* All rights reserved.
* @author Lukas Damian Opacki
*/
public class BasicG2DMask extends MovieClip
{
private var rect:GShape;
private var triangle:GShape;
public function BasicG2DMask() 
{
haxe.initSwc (this);
var config:GContextConfig = new GContextConfig (stage);
config.enableDepthAndStencil = true;
Genome2D.getInstance ().onInitialized.addOnce (onG2d);
Genome2D.getInstance ().init (config);
}
private function onG2d():void 
{
var w:Number = 100;
var h:Number = 100;
var green:GTexture = GTextureManager.createTexture ("green", new BitmapData (100, 100, false, 0x00ff00));
var red:GTexture = GTextureManager.createTexture ("red", new BitmapData (100, 100, false, 0xff0000));
rect = GNode.createWithComponent (GShape) as GShape;
rect.texture = green;
rect.setup( [0, 0, w, 0, 0, h, 0, h, w, 0, w, h],
[0, 0, 1, 0, 0, 1, 0, 1, 1, 0, 1, 1]);
triangle = GNode.createWithComponent (GShape) as GShape;
triangle.texture = red;
triangle.setup( [0,h, w/2,0, w,h],
[0,1,  .5,1, 1,1]);
Genome2D.getInstance ().root.addChild (rect.node);
Genome2D.getInstance ().root.addChild (triangle.node);
stage.addEventListener (MouseEvent.MOUSE_MOVE, onMouseMove);
stage.addEventListener (MouseEvent.CLICK, onClick);
rect.node.mask = triangle.node;
}
private function onClick(e:MouseEvent):void 
{
rect.node.mask = null;
}
private function onMouseMove(e:MouseEvent):void 
{
rect.node.y = stage.mouseY;
rect.node.x = stage.mouseX;
}
}

}
Reply all
Reply to author
Forward
0 new messages