Hi,
Moving along now…
I don’t see Lua script commands to do the following to a Sprite:
(1) Sprite [x,y] position on screen
(2) Sprite rotation degree
(3) Sprite [r,g,b] color hue changing
Let me know, thanks!
Jesse
Hi,
Moving along now…
I don’t see Lua script commands to do the following to a Sprite:
(1) Sprite [x,y] position on screen
(2) Sprite rotation degree
(3) Sprite [r,g,b] color hue changing
Let me know, thanks!
Jesse
Jesse,
Again. Go through the Side scroller tutorial. Then move on with other tutorials and documentation. All your questions so far are answered in detail on the site’s learn section. Please use it.
Sorry…I’ll play around with it some more before asking
There are strong reasons why I and others encourage you to go the tutorial and documentation route. Defold does things differently from what most people are used to. It took me quite a while to understand how to build things in Defold, and I had face to face access to the original architects. We put a lot of effort in creating learning material for that very reason. Jumping in at the deep end and playing your way to understanding is certainly possible, but it will likely take way, way more time than necessary.
You position the game object, not the sprite. go.set_position(), check API docs for details.
You rotate the game object, not the sprite. go.set_rotation(), check API docs for details.
sprite.set_constant("#mysprite", "tint", vmath.vector4(r, g, b, a))
And again, go through one tutorial, like the side scroller, and you’ll have many of the basics explained to you.
Sorry to resurrect, but I thought this may be useful for people looking for ways to modify sprites within game objects.
There is a type of solution using the 3rd method here. You can simply add a constant with a custom sprite vp (copy the original and add the position code below).
uniform mediump mat4 view_proj;
uniform mediump vec4 offset;
// positions are in world space
attribute mediump vec4 position;
attribute mediump vec2 texcoord0;
varying mediump vec2 var_texcoord0;
void main()
{
gl_Position = view_proj * vec4(position.xyz + offset.xyz, 1.0);
var_texcoord0 = texcoord0;
}
Then you set the position (or rotation is easy to add too) from the set_constant. Works a treat!
Be aware that this also breaks batching of the sprites, making each sprite a separate draw call.
Ahh yes. Sorry, good point. I’m using it for a simple effect (so, only a couple of them). Im assuming anything that has a ‘per instance’ modification of a material will do this?
Correct.