Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers AppGameKit Corner / [SOLVED] Single sprite, multiple DrawSprite commands

Author
Message
jhanson
1
Years of Service
User Offline
Joined: 19th Jun 2017
Location: USA
Posted: 12th Jun 2018 14:47
I'm out of practice and fear I'm missing something.

In this thread - https://forum.thegamecreators.com/thread/221005 - it says that if you want to draw the same sprite multiple times on the screen, you can just move it and call the DrawSprite command again. This seems to work fine for me unless I have another sprite in the way, such as a background image. In that case, only the last DrawSprite command seems to show. It doesn't seem to matter what I set the depth of each one at - same result.

For sample code, all I did was take the sample code from the old thread and add:
bg = CreateSprite(LoadImage("./background.png"))
SetSpriteDepth(bg,100)

right before the "spr = CreateSprite(0)" line.

Am I doing something wrong here or is this expected behavior?

The author of this post has marked a post as an answer.

Go to answer

Bengismo
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 12th Jun 2018 18:43
This post has been marked by the post author as the answer.
Expected behavior

None of your "draw sprites" will be seen if you have a background sprite as it will get drawn on top of them. The only sprite your seeing is one you used to draw the drawsprites and you left it there and left it visible so it gets rendered along with the background one.

Consider using clonesprite to draw multiple copies of the same sprite. Then you can just use sync() to display them all

Alternatively, instead of using sync()

Call....
Update(0)
Render()

...then do your DrawSprites here

Swap()


That way you sprites will appear over the background if you have a depth correctly set for them
Richard_6
1
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 13th Jun 2018 13:40
You can check an example in this thread.

Login to post a reply

Server time is: 2018-08-21 01:29:09
Your offset time is: 2018-08-21 01:29:09