From: Joop Q. <jq...@ho...> - 2004-10-12 15:47:57
|
Hello, last weekend I tried to do some animation with the Dynapi3. I have an animated character on the screen which can be controlled with the arrow-keys on the keyboard. That works perfectly. But when I want to control the character by clicking on (and holding down) North, East, South and West arrow pictures on the screen, it only calls the subroutine once and the character only moves a couple of pixels to the desired direction. I have to release the mousebutton and click again to trigger another event. Code: evn = {}; evn.onmousedown= function(e) { var o = e.getOrigin(); if (o=="DynObject.all.south"){ character.setLocation(character.x,character.y+5); character.setFrame(7) character.playAnimation(true,'8>7,7<8,8<7') } Then I tried triggering slide-animations with mousedown events, and stopping them with mouseup, which also worked. But then I couldn't get the actual X and Y positions of the moved character, it always started at the original slide-animation coords.. I used this code in listener.onpathstop or listener.onpathstart to update the coords, but like I said it didn't work: xx=o.getX(); yy=o.getY(); character.setX(xx); character.setY(yy); character.setPosition(xx,yy) I read some stuff about events, tried to use invokeEvent('mouseup') but that also didn't work when the mousebutton is still pressed. Can it be done, or would you recommend using the keyboard for controlling animation? Btw, I use WinXP with Mozilla 1.7, Firefox 0.9 and IExplorer 6.0 with the Dynapi3 beta. Thanks! Joop Btw I really hope there will be more Dynapi3 activity, it's a great toolkit! |
From: Leif W <war...@us...> - 2004-10-12 16:36:20
|
----- Original Message ----- From: "Joop Quadackers" <jq...@ho...> To: "dynapi-help" <dyn...@li...> Sent: Tuesday, October 12, 2004 11:44 Subject: [Dynapi-Help] Events, is it possible to keep triggering events while mousebutton is held down? > Hello, > > last weekend I tried to do some animation with the Dynapi3. I have an animated character on the screen which can be > controlled with the arrow-keys on the keyboard. That works perfectly. But when I want to control the character by clicking on > (and holding down) North, East, South and West arrow pictures on the screen, it only calls the subroutine once and the > character only moves a couple of pixels to the desired direction. I have to release the mousebutton and click again to trigger another event. I'd have to try this in code to be sure but am busy atm. :-\ Would something like this pseudocode work? I forget if an object property already exists that holds the down state or if so, what it's called. I just call it "mouse_down_flag" here. onmousedown = function { obj.mouse_down_flag = true; while ( obj.mouse_down_flag == true ) { move in specific direction; } } onmouseup = function { obj.mouse_down_flag = false; } Also try the CVS copy, as your results may vary from the beta copy. Leif > Code: > > > evn = {}; > evn.onmousedown= function(e) { > var o = e.getOrigin(); > > if (o=="DynObject.all.south"){ > character.setLocation(character.x,character.y+5); > character.setFrame(7) > character.playAnimation(true,'8>7,7<8,8<7') > } > > > > Then I tried triggering slide-animations with mousedown events, and stopping them with mouseup, which also worked. > But then I couldn't get the actual X and Y positions of the moved character, it always started at the original slide-animation coords.. > > I used this code in listener.onpathstop or listener.onpathstart to update the coords, but like I said it didn't work: > > xx=o.getX(); > yy=o.getY(); > > character.setX(xx); > character.setY(yy); > character.setPosition(xx,yy) > > > I read some stuff about events, tried to use invokeEvent('mouseup') but that also didn't work when the mousebutton is still pressed. > > Can it be done, or would you recommend using the keyboard for controlling animation? > > Btw, I use WinXP with Mozilla 1.7, Firefox 0.9 and IExplorer 6.0 with the Dynapi3 beta. > > Thanks! > > Joop > > Btw I really hope there will be more Dynapi3 activity, it's a great toolkit! > > > > ------------------------------------------------------- > This SF.net email is sponsored by: IT Product Guide on ITManagersJournal > Use IT products in your business? Tell us what you think of them. Give us > Your Opinions, Get Free ThinkGeek Gift Certificates! Click to find out more > http://productguide.itmanagersjournal.com/guidepromo.tmpl > _______________________________________________ > Dynapi-Help mailing list > Dyn...@li... > https://lists.sourceforge.net/lists/listinfo/dynapi-help > > |