[DIR/Lingo] Drag&Drop met twee mogelijke eindposities

Pagina: 1
Acties:

  • Beekforel
  • Registratie: November 2001
  • Laatst online: 08:11

Beekforel

Is eigenlijk geen vis

Topicstarter
Ik ben wat aan het prutsen met Drag & Drop en controle als het op de goede plaats staat.
Nou heb ik wel wat dingetjes gevonden, zoals op http://www.director-online.com/buildArticle.php?id=222 die ik dan twee keer toewijs aan mijn sprite omdat er twee mogelijke plaatsen zijn voor de sprites.

Met 1 sprite gaat dit prima, maar doe ik het met twee sprites dan ziet ie niet dat ze beide op de goeie plaats staan oid. Hij zet het draggable gebeuren wel uit maar geef niet de melding "You did it!".
Maak ik ergens een denkfout je? wat me niet zou verbazen met deze vage scripttaal
Of moet ik het anders oplossen?

[edit]
Ok ik heb het opgelost!
Heb het script van bovenstaand url erbij gepakt en aan de hand daarvan een nieuw script geschreven. Mijn denkwijze was wat fout, maar dat is nu opgelost. :)
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
property pMySprite   -- property of the sprite where we are working with

property pTargetH    -- horizontal target
property pTargetH2   -- second horizontal target

property pTargetV    -- vertical target
property pTargetV2   -- second vertical target

property pTargetLoc  -- combination of the targets (point)
property pTargetLoc2 -- second combination

property pTolerance  -- tolerance of the target

property pStatus     -- the status of the sprite, #inPlace or #notInPlace

on beginSprite me
  set pTargetH = 366 
  set pTargetV = 197
  
  set pTargetH2 = 649
  set pTargetV2 = 197
  
  set pTolerance = 5
  
  set pTargetLoc = point(pTargetH, pTargetV)
  set pTargetLoc2 = point(pTargetH2, pTargetV2)
  
  set pMySprite = the spriteNum of me
  set the moveableSprite of sprite pMySprite to TRUE
  
  set pStatus = #notInPlace  
end

on mouseUp me
  set testH = the locH of sprite pMySprite
  set testV = the locV of sprite pMysprite
  if abs(pTargetH - testH) < pTolerance then
    if abs(pTargetV - testV) < pTolerance then
      set the moveableSprite of sprite pMySprite to FALSE
      set the loc of sprite pMySprite = pTargetLoc
      -- alert "Links geplaatst"
      set pStatus = #inPlace
      checkWinning me
    end if
  end if
  if abs(pTargetH2 - testH) < pTolerance then
    if abs(pTargetV2 - testV) < pTolerance then
      set the moveableSprite of sprite pMySprite to FALSE
      set the loc of sprite pMySprite = pTargetLoc2
      -- alert "Rechts geplaatst"
      set pStatus = #inPlace
      checkWinning me
    end if
  end if
end

on checkWinning me
  set statusList = []
  sendAllSprites (#reportStatus, pMySprite, statusList)
  if getOne(statusList, #notInPlace) then
    nothing
  else
    puzzleDone me
  end if
end

on reportStatus me, whichSprite, statusList
  if whichSprite <> pMySprite then
    add statusList, pStatus
  end if
end

on puzzleDone me
  alert "Alles klaar!"
end

[ Voor 65% gewijzigd door Beekforel op 04-01-2005 19:06 ]


Verwijderd

Kan je het gebied waar de sprite (puzzelstukje) moet komen te staan niet markeren met een onderliggende sprite (juiste plaats). Een vierkant die je dan onzichtbaar maakt. Er is een functie om te checken of een sprite binnen de boundary van een andere sprite staat. "the constraint" d8 ik.