[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[pygame] checking mouse button state
- To: pygame-users@xxxxxxxx
- Subject: [pygame] checking mouse button state
- From: "Jake b" <ninmonkeys@xxxxxxxxx>
- Date: Sat, 10 Jan 2009 21:47:12 -0600
- Delivered-to: archiver@xxxxxxxx
- Delivered-to: pygame-users-outgoing@xxxxxxxx
- Delivered-to: pygame-users@xxxxxxxx
- Delivery-date: Sat, 10 Jan 2009 22:47:15 -0500
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type; bh=y5PIp1hwfdjq7SnF1biX/NwUVm+Dlu1tcIfnjYxfGFw=; b=YLSjwLokbmYzLBHkhY3Zy7aCQ0lV6dqcFRtlQ76xS0O+np7hq9yh0yn/XES8yv1KGh FJWLmkgSdRjkC1bA9lfTY2Mxex+/WQmnU9iF1RNcr3VI4r3KlVC8VUbvypDKgITbvdgt p0RtaGr8tMd/CK57tZybcvLjMgjLBLIYtjcGI=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type; b=r4g1z+F8TU7DaqI5Xrf4FsarUZdbgyvxI5SK/bFqOyA8L/6txHO7ImHoy2n1fTFsPK 7soZKjS4mpJw9si+X/+sddzA8eoxgNysp4S5FRHngoKbrM5Yl6RNoX6ePxjP+TD6wiCv 3lFuUBrCgXZ7BDvd/8FnVijOlvc6cZLejXN1g=
- Reply-to: pygame-users@xxxxxxxx
- Sender: owner-pygame-users@xxxxxxxx
I want to do a simple:
if LeftMouseDown(): fire()
But it is failing. Right now both ways I try, it only says the button is down if the mouse is moving. If I stay at the same x,y coord, it says the button not pressed(but it is).
# code:
events = pygame.event.get()
for event in events:
# 1) this block doesn't seem to work right unless moving mouse:
(b1,b2,b3) = pygame.mouse.get_pressed()
if b1:
self.player.fire()
print 'down'
#else, tried: 2)
if self.mouse.down:# or True:
self.player.fire()
print 'down'
if event.type == MOUSEMOTION: pass
elif event.type == MOUSEBUTTONDOWN: self.mouse.down = True
elif event.type == MOUSEBUTTONUP: self.mouse.down = False
I'm surprised at method #2 failing, since I never change the value of mouse.down anywhere else in the code, except those two lines above.
--
Jake