Be a Supporter!

Click mouse to shoot?

  • 379 Views
  • 5 Replies
New Topic Respond to this Topic
ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Click mouse to shoot? 2007-06-16 16:29:05 Reply

I have this code for my ship to shoot:
if (Key.isDown(Key.CONTROL))

I did it like this because it's the only way I know how (pressing a button I mean)
I want to change it so all the things I have after this will be triggered by a left mouse click instead of pressing ctrl. What would I put? I think it's something like mouseDown or mousePress? I tried using those but it doesn't work.


AS: Main

Don't read this sentence.

ninjitsuwarrior
ninjitsuwarrior
  • Member since: Apr. 28, 2006
  • Offline.
Forum Stats
Member
Level 24
Game Developer
Response to Click mouse to shoot? 2007-06-16 17:00:42 Reply

onMouseDown=function(){
// your shoot code
}

ChilliDog
ChilliDog
  • Member since: Feb. 16, 2007
  • Offline.
Forum Stats
Member
Level 16
Blank Slate
Response to Click mouse to shoot? 2007-06-16 21:00:01 Reply

Exactly what I needed, thank you.


AS: Main

Don't read this sentence.

InfallibleSquirrel
InfallibleSquirrel
  • Member since: Jun. 22, 2006
  • Offline.
Forum Stats
Member
Level 10
Programmer
Response to Click mouse to shoot? 2007-06-16 23:08:42 Reply

or you could sya
if(Key.isDown(1)){
//whatever
}
cos 1 is the keycode for leftclick


The squirrel shall always triumph

BBS Signature
Ninja-Without-Sight
Ninja-Without-Sight
  • Member since: Jul. 13, 2006
  • Offline.
Forum Stats
Member
Level 13
Blank Slate
Response to Click mouse to shoot? 2007-08-12 19:13:21 Reply

*bump*

sandypaw
sandypaw
  • Member since: Jun. 28, 2007
  • Offline.
Forum Stats
Member
Level 10
Blank Slate
Response to Click mouse to shoot? 2007-08-12 20:29:44 Reply

nice one infallablesquirrel, (thats your name right) taught me something =)


=3