[Gambas-user] DrawingArea capabilities

jbskaggs jbskaggs at ...1871...
Sat Apr 4 19:54:00 CEST 2009


On every screen refresh the computer redraws the area.  So you only need to
change the x and y points of your picture being drawn. 

so something like : Mind you I only did the x coordinate you will have to do
the y, and I also did a example with the right arrow key.

public_sub drawingarea1_keypress() ' check for keypress

if key.code=key.right  then yourgraphicx = 3     ''distance to move graphic,
yourgraphicx is a integer you have to define as a public integer and
depending on your sprite size and refresh rate will have to be adjusted.

end


public_sub drawingarea1_keyrelease() ' check for keyrelease for reference
using keys

if key.code=key.right  then yourgraphicx = 0      'sets the space to move
the grapphic to zero so it will stay in place

end


PUBLIC SUB drawingarea1_MouseDown()  ' this initiates my mouse movement
  IF Mouse.x < moveyourgraphicx THEN yourgraphicx = -3
  IF Mouse.x > moveyourgraphicx THEN yourgraphicx = 3
  mousemovetox = Mouse.X
  PRINT Mouse.X ' this checks to see if my control is reading the mouse
  mouseactive = 1' tells that I have an active mouse goto point
END



public sub redrawarea_click()

IF mouseactive = 1 'see if mouse is in control
IF impmoving = -3 'for mouse control
    IF imposx < mousemovetox 
    yourgraphicx = 0
    mouseactive = 0
    ENDIF 
END IF

IF mouseactive = 1 'see if mouse is in control
IF yourgraphicx = -3 'for mouse control
    IF moveyourgraphicx < mousemovetox 
    yourgraphicx = 0
    mouseactive = 0
    ENDIF 
END IF


moveyourgraphic+=yourgraphicx  'moveyourgraphic is a integer that needs to
be declared, like any interger variable it can have any name

draw.begin(...

Draw.Image(image, moveyourgraphicx, y)

draw.end


I haven't checked this for syntax or whatever just typed from memory so you
will need to make sure the commands are correct but I use this in games
alot.

JB Skaggs



Tomas Eroles i Forner wrote:
> 
> Hi all
> Is there any way to draw mobile objects on a DrawingArea?
> That is, is it possible to draw something and after to move it with
> mouse?
> 
> The idea is to draw things in a drawingarea? and when required, to move
> them using the mouse
> 
> Thanks in advance
> ------------------------------------------------------------------------------
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 
> 

-- 
View this message in context: http://www.nabble.com/DrawingArea-capabilities-tp22881901p22886113.html
Sent from the gambas-user mailing list archive at Nabble.com.





More information about the User mailing list