does anyone know how you could click on an entity,picture,sprite, etc., to do an action?
txs
txs
Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer() cam = CreateCamera() MoveEntity cam, 0, 0, -15 ;create sprite sp = CreateSprite() Color 64, 0, 0 Rect 0, 0, 64, 64 Color 255, 255, 255 Text 32, 16, "sprite", 1, 1 Text 32, 32, "TEST", 1, 1 tex = CreateTexture(64, 64) CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex) EntityTexture sp, tex EntityBox sp, -1, -1, -1, 2, 2, 2 EntityPickMode sp, 3 ;create image img = CreateImage(64, 64) Color 0, 64, 0 Rect 0, 0, 64, 64 Color 255, 255, 255 Text 32, 16, "image", 1, 1 Text 32, 32, "TEST2", 1, 1 GrabImage img, 0, 0 cube = CreateCube() MoveEntity cube, 4, 4, 0 EntityPickMode cube, 2 Repeat RenderWorld() DrawBlock img, 100, 100 If MouseDown(1) ;check if sprite is clicked CameraPick cam, MouseX(), MouseY() If PickedEntity() = sp Then Text 400, 50, "sprite!", 1, 1 End If ;check if cube is clicked If PickedEntity() = cube Then Text 400, 50, "cube!", 1, 1 End If ;check if image is clicked If RectsOverlap(MouseX(), MouseY(), 1, 1, 100, 100, 64, 64) Then Text 400, 50, "image!", 1, 1 End If End If Flip Until KeyHit(1) End
Graphics3D 800, 600, 0, 2 SetBuffer BackBuffer() cam = CreateCamera() MoveEntity cam, 0, 0, -15 ;create sprite sp = CreateSprite() Color 64, 0, 0 Rect 0, 0, 64, 64 Color 255, 255, 255 Text 32, 16, "sprite", 1, 1 Text 32, 32, "TEST", 1, 1 tex = CreateTexture(64, 64) CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex) EntityTexture sp, tex EntityBox sp, -1, -1, -1, 2, 2, 2 EntityPickMode sp, 3 ;create image img = CreateImage(64, 64) Color 0, 64, 0 Rect 0, 0, 64, 64 Color 255, 255, 255 Text 32, 16, "image", 1, 1 Text 32, 32, "TEST2", 1, 1 GrabImage img, 0, 0 door = CreateCube() MoveEntity door, 4, 4, 0 EntityPickMode door, 2 Repeat RenderWorld() DrawBlock img, 100, 100 If MouseDown(1) ;check if sprite is clicked CameraPick cam, MouseX(), MouseY() If PickedEntity() = sp Then Text 400, 50, "sprite!", 1, 1 End If ;check if cube is clicked If PickedEntity() = door Then Text 400, 50, "door!", 1, 1 End If ;check if image is clicked If RectsOverlap(MouseX(), MouseY(), 1, 1, 100, 100, 64, 64) Then Text 400, 50, "image!", 1, 1 End If End If Flip Until KeyHit(1) End
Function SetEntityPickMode(ent, pm) EntityPickMode ent, pm For i = 1 To CountChildren(ent) g = GetChild(ent, i) SetEntityPickMode g, pm Next End Function