# Sprite Spawning based on Variables

**URL:** <https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897>\
**Category:** Questions about Thunkable X\
**Tags:** beginner\
**Created:** [May 2, 2021, 8:30pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897 "2021-05-02T20:30:35Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:30pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/1 "2021-05-02T20:30:35Z")

</div>

Hi,

I am working on an game and I am trying to generate sprites on a canvas based on a variable, however this is not working. Any help is appreciated.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 2, 2021, 8:31pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/2 "2021-05-02T20:31:45Z")

</div>

Show your blocks? Can’t help without more info!

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:34pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/3 "2021-05-02T20:34:55Z")

</div>

ok, sorry about that! [code|508x500](https://community.thunkable.com/uploads/short-url/g8elODMALcajrcHc9eyVyNpr970.png)

---

<div class="post-metadata">

**Author:** ![Dean\_Artis](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dean\_Artis](https://community.thunkable.com/u/Dean_Artis)\
**Post date:** [May 2, 2021, 8:35pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/4 "2021-05-02T20:35:46Z")

</div>

The quality is awful. Show them properly like everyone else does.

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:36pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/5 "2021-05-02T20:36:58Z")

</div>

Sorry? This is my first time asking for help so I don’t really know “what everyone else does”.

---

<div class="post-metadata">

**Author:** ![Dean\_Artis](https://avatars.discourse-cdn.com/v4/letter/d/a8b319/32.png) [@Dean\_Artis](https://community.thunkable.com/u/Dean_Artis)\
**Post date:** [May 2, 2021, 8:37pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/6 "2021-05-02T20:37:36Z")

</div>

Show a proper image of your blocks please.

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:40pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/7 "2021-05-02T20:40:39Z")

</div>

I think this is “proper”? If not feel free to let me know!

 ![code2electricboogaloo.](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/d/0/d048643f141b93080936f3b26ad6af42d5632025.png)

---

<div class="post-metadata">

**Author:** ![cyberdriver](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cyberdriver](https://community.thunkable.com/u/cyberdriver)\
**Post date:** [May 2, 2021, 8:45pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/8 "2021-05-02T20:45:43Z")

</div>

What specifically isn’t working? Where you show and hide sprites?

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:47pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/9 "2021-05-02T20:47:17Z")

</div>

Yes, it loads them both for some reason regardless of what the variable is. It’s rather annoying. I also tried generating the sprites but it just led to the same issue.

---

<div class="post-metadata">

**Author:** ![cyberdriver](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cyberdriver](https://community.thunkable.com/u/cyberdriver)\
**Post date:** [May 2, 2021, 8:47pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/10 "2021-05-02T20:47:53Z")

</div>

Do both sprites start out as hidden?

---

<div class="post-metadata">

**Author:** ![cyberdriver](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cyberdriver](https://community.thunkable.com/u/cyberdriver)\
**Post date:** [May 2, 2021, 8:48pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/11 "2021-05-02T20:48:50Z")

</div>

I would try adding a “hide sprite2” and a “hide sprite3” blocks as first in “when screen1 starts”

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 8:51pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/12 "2021-05-02T20:51:10Z")

</div>

I just did as you suggested with no luck ☹ . Still have both sprites spawning in at the same time.

---

<div class="post-metadata">

**Author:** ![cyberdriver](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cyberdriver](https://community.thunkable.com/u/cyberdriver)\
**Post date:** [May 2, 2021, 8:57pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/13 "2021-05-02T20:57:19Z")

</div>

I have had issues with initializing variables and using them at the same time. Try adding a “wait 1 second” block before you set variable BHealth.

---

<div class="post-metadata">

**Author:** ![2021colhatgrk34](https://avatars.discourse-cdn.com/v4/letter/2/9de053/32.png) [@2021colhatgrk34](https://community.thunkable.com/u/2021colhatgrk34)\
**Post date:** [May 2, 2021, 9:01pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/14 "2021-05-02T21:01:10Z")

</div>

THANK YOU SO MUCHHHHHH 🙂 .

---

<div class="post-metadata">

**Author:** ![cyberdriver](https://avatars.discourse-cdn.com/v4/letter/c/5e9695/32.png) [@cyberdriver](https://community.thunkable.com/u/cyberdriver)\
**Post date:** [May 2, 2021, 9:02pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/16 "2021-05-02T21:02:36Z")

</div>

It worked? That’s good I was typing another solution and didn’t see this right away. Good luck!

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/sprite-spawning-based-on-variables/1258897/17 "2024-11-08T13:22:43Z")

</div>


