GetSpriteVertexX
Xpos# = GetSpriteVertexX(SpriteIndex, VertexIndex)
 
Parameters:

    SpriteIndex = The Sprite you wish to query
    VertexIndex = The vertex you wish to read ranges between (0 and 3)
Returns:

    Xpos# = The X position of this vertex
 
     The GetSpriteVertexX function returns the position of a sprite corner vertex. This position is post rotation & scaling.

      The corner vertex of a sprite are ordered in a clock wise fashion. Vertex zero being the Top-Left, Vertex One is the Top-Right, Vertex three is the bottom/right and Vertex four is the Bottom-Left

So if the image isn't rotated, they'd look like this.

(0)-----(1)
| |
| |
| |
| |
(3)-----(2)




FACTS:


      * GetSpriteVertexX returns the position of the vertex after rotation and scaling have been applied to the sprite.

      * Also see PositionSprite, ScaleSprite, RotateSprite




Mini Tutorial:


      This example creates a random image, creates 10 randomly positioned sprites on the screen using this image.

The main loop rotates the sprites and draws the bounding egdes via reading the sprites vertex positions.


  
; Make a Blue image, with circle on it
  Cls RGB(0,0,255)
  For lp =0 To 100
     CircleC Rnd(100),Rnd(100),Rnd(5),1,RndRGB()
  Next
  GetImage 1,0,0,100,100
  PrepareFXImage 1
  
; Make 10 sprites
  For spr=1 To 10
     
   ; Create the sprite
     CreateSprite Spr
     
   ; psition the spriotye randomly on the screen
     x=Rnd(GetScreenWidth())
     y=Rnd(GetScreenHeight())
     PositionSprite Spr,x,y
     
   ; assign this sprite Image #1
     SpriteImage Spr,1
     
   ; Set Sprite Drawmode to rotated
     SpriteDrawMode Spr,2
     
     
     CenterSpriteHandle spr
     SpriteCollision spr,on
     
   ; Set sprite collision to Rotated rectangles
     SpriteCollisionMode Spr,1
  Next
  
  
  
  Do
     Cls RGB(0,0,0)
     
     
     DrawAllSprites
     
   ; start for/next loop from 1 to 10
     For spr=1 To 10
        
      ; Turn this sprite
        TurnSprite spr,spr*0.33
        
      ; Read the Sprites Vertex positions
        X1#=GetSpriteVertexX(spr,0)
        Y1#=GetSpriteVertexY(spr,0)
        
        X2#=GetSpriteVertexX(spr,1)
        Y2#=GetSpriteVertexY(spr,1)
        
        X3#=GetSpriteVertexX(spr,2)
        Y3#=GetSpriteVertexY(spr,2)
        
        X4#=GetSpriteVertexX(spr,3)
        Y4#=GetSpriteVertexY(spr,3)
        
      ; Draw lines to connect the edges
        Line x1#,y1#,x2#,y2#
        Line x2#,y2#,x3#,y3#
        Line x3#,y3#,x4#,y4#
        Line x4#,y4#,x1#,y1#
        
     Next
     
     Sync
  Loop
  
  


 
Related Info: GetSpriteOldX | GetSpriteOldY | GetSpriteOldZ | GetSpriteVertexY | GetSpriteX | GetSpriteY | GetSpriteZ :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com