Jump to content

[SOLVED] WidgetSpriteVideo stencil


photo

Recommended Posts

Hi,

I'm trying to use WidgetSpriteVideo to display video on in-game screen models and it works pretty fine. However, I can't have the video cropped properly. As I show on my screenshot, I'd like the right part of the video not being displayed. I've made some research, found this topic and tried to do the same.

 

Here is the code in which I try to create my WidgetSpriteVideo and attach it to my GuiObject:

// gui: Gui of my ObjectGui
WidgetHBox container = new WidgetHBox(gui);
container.setStencil(1);

WidgetSpriteVideo videoSprite = new WidgetSpriteVideo(gui, "MyVideo.ogv", 0);
videoSprite.setFlags(GUI_ALIGN_OVERLAP);

container.addChild(videoSprite);
gui.addChild(container);

What am I missing?

 

Thanks,

Alexandre.

 

post-1678-0-33465300-1457623961_thumb.png

Link to comment

Hi,

Can you use ObjectGuiMesh rather than ObjectGui?

// ObjectGuiMesh on left side of image
ObjectGuiMesh object_mesh_gui = node_cast(engine.editor.getNodeByName("ObjectGuiMesh_0"));
Gui gui = object_mesh_gui.getGui();

WidgetHBox container = new WidgetHBox(gui);
container.setStencil(1);

WidgetSpriteVideo videoSprite = new WidgetSpriteVideo(gui, "MyVideo.ogv", 0);
videoSprite.setFlags(GUI_ALIGN_OVERLAP);

container.addChild(videoSprite);
videoSprite.setPosition(100,100);
container.setPosition(100,100);
container.setWidth(100);
container.setHeight(100);

gui.addChild(container,GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED);

// ObjectGui on right side of image
ObjectGui object_gui = node_cast(engine.editor.getNodeByName("ObjectGui_0"));
gui = object_gui.getGui();

container = new WidgetHBox(gui);
container.setStencil(1);

videoSprite = new WidgetSpriteVideo(gui, "MyVideo.ogv", 0);
videoSprite.setFlags(GUI_ALIGN_OVERLAP);

container.addChild(videoSprite);
videoSprite.setPosition(100,100);
container.setPosition(100,100);
container.setWidth(100);
container.setHeight(100);

gui.addChild(container,GUI_ALIGN_OVERLAP | GUI_ALIGN_FIXED);

post-1412-0-08804700-1458026412_thumb.png

Link to comment

Hi,

No it is not a bug. I found solution which works with ObjectGui. You must rewrite your code in that way.

ObjectGui object_mesh_gui = node_cast(engine.editor.getNodeByName("ObjectGui_0"));
Gui gui = object_mesh_gui.getGui();

// gui: Gui of my ObjectGui
WidgetHBox container = new WidgetHBox(gui);
container.setStencil(1);

WidgetSpriteVideo videoSprite = new WidgetSpriteVideo(gui, "MyVideo.ogv", 0);
container.addChild(videoSprite, GUI_ALIGN_OVERLAP);
gui.addChild(container, GUI_ALIGN_EXPAND);

Unfortunately addChild function has two arguments, name of the second is flags. The second argument has default value 0. And when you write

videoSprite.setFlags(GUI_ALIGN_OVERLAP);
container.addChild(videoSprite);

it means

videoSprite.setFlags(GUI_ALIGN_OVERLAP);
container.addChild(videoSprite, 0);


You can use

container.addChild(videoSprite);
videoSprite.setFlags(GUI_ALIGN_OVERLAP);

or simple

container.addChild(videoSprite, GUI_ALIGN_OVERLAP);
Link to comment
  • 4 weeks later...
×
×
  • Create New...