; HandleSprite Example ; -------------------- Graphics3D 640,480,0,2 SetBuffer BackBuffer() camera=CreateCamera() PositionEntity camera,0,1.5,-5 light=CreateLight() RotateEntity light,45,45,0 ground=CreatePlane() EntityTexture ground,LoadTexture("media/MossyGround.BMP") ; A spinning logo sprite logo=LoadSprite("media/b3dlogo.jpg") ScaleSprite logo,1,0.5 PositionEntity logo,0,1.5,0 ; A small marker fixed at the sprite's position, so you can see what ; point the sprite pivots around pin=CreateSphere(8) ScaleEntity pin,0.05,0.05,0.05 EntityColor pin,255,60,60 EntityFX pin,1 PositionEntity pin,0,1.5,0 ; A sprite extends from -1,-1 to +1,+1 around its handle hx#=0 hy#=0 info$="HandleSprite logo,0,0 (centre - spins in place)" angle#=0 While Not KeyDown(1) ; Space cycles through three handle positions If KeyHit(57) preset=(preset+1) Mod 3 If preset=0 Then hx=0 : hy=0 : info$="HandleSprite logo,0,0 (centre - spins in place)" If preset=1 Then hx=0 : hy=-1 : info$="HandleSprite logo,0,-1 (bottom edge - swings like a clock hand)" If preset=2 Then hx=-1 : hy=-1 : info$="HandleSprite logo,-1,-1 (corner - orbits the red pin)" EndIf ; HandleSprite moves the point the sprite hangs from and spins around HandleSprite logo,hx,hy ; Keep the sprite turning so the pivot point is obvious angle=angle+2 RotateSprite logo,angle RenderWorld Text 0,0,"Space: cycle handle position Esc: exit" Text 0,20,info$ Flip Wend End