Why does this work?
Output - beaver sprite rotates to face wherever you touch on the screen/
But this doesn’t work:
Output - beaver sprite ignores touches on screen.
Why does this work?
But this doesn’t work:
Output - beaver sprite ignores touches on screen.
Bumping this one to the top
The top blocks use a sprite object but the bottom blocks use the word “sprite” which doesn’t relate to an actual sprite in Thunkable.
Hi Tatiang, I’m trying to create a setup where the behaviour of the sprites on my canvas is governed by text variables - is there no way to do this in thunkable?
I suppose what I’m asking is, how can I create a variable which Thunkable will recognise as a sprite object?
Without that functionality, it would take a hell of a lot of repeated blocks to generate any meaningful animations.
Bumping this one back to the top in hopes of getting answer, is it possible?
Can you give an example of this that wouldn’t work with standard app variables? I assume you’re wanting to do something like sprite1.tag, sprite2.tag, etc. where tag is a unique value…?
Hi Tatiang,
I think it would be easiest for me to set a simple challenge down here.
You have two sprites on the canvas - sprite1 and sprite 2.
The behaviour we are targeting is when the user presses on the screen, sprite 1 will move towards the active pointer and sprite 2 will rotate to face sprite 1 in its new position. We can create this effect with this block:
Your challenge is to initiate these two variables to a value which will enable this block to show the same behaviour:
The reason that this is the challenge is that in order to build anything substantial using the canvas functionality, I will need a way of linking variables to sprites. if I I can do that then I can build something with 100’s of blocks rather than 1000’s.
Project: Thunkable
You can do this with Any Component blocks. Use variables to represent the sprite component indexes (1 for the first sprite, 2 for the second sprite, etc.).
Project link: Thunkable
Thanks Tatiang, what governs the index number of the sprites? Is it the order they appear in your component tree? (1 for the first, 2 for the 2nd etc.)
Yes, the order in the component tree. If you are placing them manually or spawning them then you will know the order. It’s tougher to figure out which sprite is which based on a condition. But you still can… you have to find out where in the list of all Sprites the component ID of that sprite is listed and then use that as the value of app variable Sprite
.