danni.coy Posted July 26, 2011 Posted July 26, 2011 I can get get WidgetSprite.setLayerTransform to work when called from a callback but when I try to call it from my main update loop (for say a layer that tracks the location of an object dynamically) I don't see any change in the layer.
manguste Posted July 27, 2011 Posted July 27, 2011 Could you provide us with a test scene to reproduce it?
danni.coy Posted July 27, 2011 Author Posted July 27, 2011 I figured out how to get around it. I set up a callback for GUI_CHANGED and then ran Widget.runCallback(GUI_CHANGED); in my update loop. something like the following should reproduce the problem: WidgetSprite sprite; Image image; int testlayer; int back =0; int pos = 5; int init() { sprite = new WidgetSprite(); image = new Image("library/textures/building/library_rubber_d.dds"); sprite.setImage(image); testlayer = sprite.addLayer(); sprite.setLayerTexture("library/textures/building/library_gold_clear_s.dds"); engine.gui.addChild(sprite,GUI_ALIGN_CENTER); sprite.setLayerTransform(testlayer,translate(vec3(pos,20.0f,0.0f)); return 1; } int update() { sprite.setLayerTransform(testlayer,translate(vec3(pos,20.0f,0.0f))); if(back==0) { pos += 5; if(pos > image.getWidth() {back = 1}; } else { pos -= 5; if (pos <= 0) {back = 0;} } return 1; }; int shutdown() { return 1;}
manguste Posted July 28, 2011 Posted July 28, 2011 GUI_CHANGED is not supported for WidgetSprite since there is basically no state that can be changed for the image. Our developer has created a nice test scene with WidgetSprite callbacks for you. Hope this helps. test_widgetsprite.cpp test_widgetsprite.world
danni.coy Posted July 28, 2011 Author Posted July 28, 2011 GUI_CHANGED is not supported for WidgetSprite since there is basically no state that can be changed for the image. Our developer has created a nice test scene with WidgetSprite callbacks for you. Hope this helps. That's more or less what I had already figured out... Thankyou for your help :)
Recommended Posts