|
Prev: move sprite in time
Next: H.264 trouble
From: Darrel Hoffman on 31 Mar 2008 20:00 Is there a way to force the pickup of a moveable sprite via code? Let's explain the problem with a little diagram here, (pardon my horrible ASCII art, which is probably font-width-dependant). I've got a small icon (A) inside a larger rectangle (B), like so: ____________ | ____ | | |_A_ | B | |___________| Now, icon (A) is a moveable sprite, and can be dragged into a certain location elsewhere on the stage. (B) is a box with a bit of descriptive text regarding icon (A). (There are actually 4 sprites involved, but (A) is the only one that moves.) What I want to do is make it so that clicking anywhere within box (B) will cause the icon (A) to jump into your mouseLoc and then be draggable, just as if you'd clicked directly onto (A). Now, I've put script onto the box (B) like so: on mouseDown me sprite(A).loc = the mouseLoc pass end This indeed causes the sprite to jump under the mouseLoc, but it won't drag - you have to click again in order to pick it up. I tried adding a "sprite(A).mouseDown()" to trick it into believing there was an actual mouse event, but this had no effect. (This technique DOES activate any script MouseDown events on sprite (A), but it doesn't cause it to be draggable.) The "pass" command doesn't seem to be doing anything here either. (In fact, I've almost never gotten that thing to work properly - it really doesn't seem to do what the docs say it does.) Is there some way to cheat the computer into thinking you clicked on the sprite when you really didn't?
From: Lukewig on 31 Mar 2008 21:36 Hi, I don't think you can pass the 'click to start drag'. Its pretty easy to do it in lingo though. -- Behaviour on the clickable sprite (B) on mouseDown me targetSprite = A tmp = script("FollowMouse").new(targetSprite) end -- Parent Script "FollowMouse" property mySprite on new (me, whatSpriteToChase) mySprite = sprite(whatSpriteToChase) mySprite.loc = the mouseLoc mySprite.scriptInstanceList.append(me) end on enterframe (me) if the mouseDown then mySprite.loc = the mouseLoc else mySprite.scriptInstanceList.deleteOne(me) end if end
|
Pages: 1 Prev: move sprite in time Next: H.264 trouble |