…that should move from left to right to imitate a light effect.
What I’ve achieved so far:
Logo (Parent)
Box as child (one line) as stencil mask
Logo as grandchild
The problem: If I animate the position.x of the box, the second logo (grandchild) moves also. I could probably reverse the movement by animating the logo’s position.x too but that looks overcomplicated to me. Is there an easy why to achieve that?
The problem with your approach is that the child (the box) would be cut off (stencil mask) by the parent’s box not by the parent’s non-transparent area.
And use rotated_coords in dist_from_stripe instead.
You can animate it with gui.set() in a .gui_script:
function init(self)
self.box_node = gui.get_node("box")
self.position_x = 0
end
function update(self, dt)
self.position_x = self.position_x + 0.01
if self.position_x > 1.5 then self.position_x = -0.5 end
gui.set(self.box_node, "stripe_data", vmath.vector4(self.position_x, 0.2, 0.2, 0))
end
Effect:
Project (let it be also my entry to Defold Community Challenge ):
And I think I made a more complicated solution actually
But answering your question - yes, animating the position simultaneously in the other direction is simpler - it’s just one additional line of code in the end!
I just tested your code and received the following warning:
WARNING:GAMESYS: Material /assets/shiny_material/shiny_gui.materialc has specified a fragment constant named 'tint', but it does not exist or isn't used in any of the shaders.
You probably forgot to add the part where you can manipulate the color of the stripe
Additionally it might make sense to switch to the modern pipeline.