Sprites

Blitz3D Forums/Blitz3D Beginners Area/Sprites

Happy Llama(Posted 2012) [#1]
How would I take a picture and position it in 3D space? I tried LoadSprite and PositionEntity commands but I get the error "entity does not exist".


Yasha(Posted 2012) [#2]
"Entity does not exist" means there's first and foremost an error in your logic code. You'll have to post a snippet so we can point that out. It could be that what you're doing with the sprite itself is largely correct.


Happy Llama(Posted 2012) [#3]
LoadSprite and PositionEntity are the only commands I'm using. Is there a different command for positioning sprites?


Midimaster(Posted 2012) [#4]
you have to take care about, that the variable that contains the entity is still avaiable when try to position it. This will cause an error:

Graphics3D 800,600
...
Function LoadIt()
     Sprite=LoadSprite("test.png")
End Function

Function MoveIt()
    MoveEntity Sprite,1,0,0
End Function


Better: Declare the variable Sprite as Global:
Graphics3D 800,600
Global Sprite%
...
Function LoadIt()
     Sprite=LoadSprite("test.png")
End Function

Function MoveIt()
     MoveEntity Sprite,1,0,0
End Function


The second reason, why the entity does not exist, ist because the image was not found. You can test this with a additional code line:

if this does not work...
Graphics3D 800,600
Global Sprite%
...
     Sprite=LoadSprite("test.png")
     MoveEntity Sprite,1,0,0



and this works....
Graphics3D 800,600
Global Sprite%
...
     Sprite=LoadSprite("test.png")
     Sprite=CreateSprite()
     MoveEntity Sprite,1,0,0

... the image was not found!


Happy Llama(Posted 2012) [#5]
The Sprite=CreateSprite() AndMoveEntity Sprite,1,0,0 commands work but when I try to load an image that I have already loaded in my code, I get the same error.


Yasha(Posted 2012) [#6]
It's probably something like MidiMaster's examples. That's why a snippet is really useful in these cases. We can't tell you what you're doing wrong without seeing it.