MouseMove Events With Sprites

Discussion in 'Code Samples & Tips' started by eww245, Apr 15, 2009.

  1. eww245

    eww245 Member Licensed User

    As it turns out it is possible to Move Sprites with the Door Library.:sign0060:

    I have included a modified SpriteExample that allows this.

    In other situations it can be used like this, no Timer is needed unless Sprite.Velocity is used.

    Code:
    Sub Globals
         mousedown = 
    false
    End Sub

    Sub App_Start
         gw.New1(
    "Form1",0,0,Form1.Width,Form1.Height)
               o.New1(
    False)  'Door Object added after GameWindow created
               o.FromLibrary ("main.gw","_gw",B4PObject(2))
    'Door Events
                eMove.New1(o.Value,"MouseMove"
                eUp.New1(o.Value, 
    "MouseUp")
                ePaint.New1(o.Value,
    "Paint"'Start the GameWindow without a Timer
         Sprite.New2(AppPath & "\image.png",1,44,44,1)
    gw.Tick 
    'It Seems to me that using a lot of Ticks, prevents white flashes
         Form1.Show
    End Sub

    Sub ePaint_newEvent
    o.Value = ePaint.Data
         gw.Tick 
    End Sub

    Sub gw_CollisionMouse    
       mousedown = 
    True 'move only when pressing the Sprite area of the GameWindow
    gw.Tick
    End Sub

    Sub eUp_NewEvent
    o.Value = eUp.Data
        mousedown = 
    false 
    gw.Tick
    End Sub

    Sub eMove_NewEvent
    o.Value = eMove.Data
        x = o.GetProperty(
    "X")
        y = o.GetProperty(
    "Y")

         
    If (mousedown) then
    Sprite.X = x
    Sprite.Y = y
         
    End If

    gw.Tick
    End Sub
     

    Attached Files:

Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice