> But only the on_key_press function is recognised. Would it be better to
have one or the other?
If you're handling key presses you should use the appropriate event
handler. Anything that needs to be run that isn't a user input event e.g.
simulation should be scheduled with pyglet.clock.schedule, schedule_once or
schedule_interval
> But only the on_key_press function is recognised. Would it be better to
> have one or the other?
That is certainly possible, you just need to schedule the update(dt)
function to be called -- it's not an event handler that's automatically
handling some event like on_key_press(...) is.
Though as Adam already alluded to, just because it's possible doesn't mean
it's necessarily the best way to do it.
On Fri, Oct 12, 2012 at 4:10 AM, Nathan <nathan.sto...@gmail.com> wrote:
> On Wed, Oct 10, 2012 at 9:34 PM, Wallace Davidson <wallace...@gmail.com>wrote:
>> Is it possible to have both of these in a program? I have:
>> @window.event
>> def on_key_press(symbol, modifiers):
>> if symbol == key.ESCAPE:
>> return pyglet.event.EVENT_HANDLED
>> But only the on_key_press function is recognised. Would it be better to
>> have one or the other?
> That is certainly possible, you just need to schedule the update(dt)
> function to be called -- it's not an event handler that's automatically
> handling some event like on_key_press(...) is.
> Though as Adam already alluded to, just because it's possible doesn't mean
> it's necessarily the best way to do it.
> ~ Nathan
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To post to this group, send email to pyglet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> pyglet-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
On Thu, Oct 11, 2012 at 2:22 PM, Wallace Davidson <wallace...@gmail.com>wrote:
> I had thought the on_key_press one was to check when a key was pressed and
> the update function checked whether a key was held down. Is that right? :/
No.
The update function is just a function. If you want it to be called, you
need to make something call it.
On Fri, Oct 12, 2012 at 11:37 AM, Nathan <nathan.sto...@gmail.com> wrote:
> On Thu, Oct 11, 2012 at 2:22 PM, Wallace Davidson <wallace...@gmail.com>wrote:
>> I had thought the on_key_press one was to check when a key was pressed
>> and the update function checked whether a key was held down. Is that right?
>> :/
> No.
> The update function is just a function. If you want it to be called, you
> need to make something call it.
> ~ Nathan
> --
> You received this message because you are subscribed to the Google Groups
> "pyglet-users" group.
> To post to this group, send email to pyglet-users@googlegroups.com.
> To unsubscribe from this group, send email to
> pyglet-users+unsubscribe@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/pyglet-users?hl=en.
> That makes sense now, thanks for the help guys :)
> On Fri, Oct 12, 2012 at 11:37 AM, Nathan <nathan.sto...@gmail.com> wrote:
>> On Thu, Oct 11, 2012 at 2:22 PM, Wallace Davidson <wallace...@gmail.com>wrote:
>>> I had thought the on_key_press one was to check when a key was pressed
>>> and the update function checked whether a key was held down. Is that right?
>>> :/
>> No.
>> The update function is just a function. If you want it to be called, you
>> need to make something call it.
>> ~ Nathan
>> --
>> You received this message because you are subscribed to the Google Groups
>> "pyglet-users" group.
>> To post to this group, send email to pyglet-users@googlegroups.com.
>> To unsubscribe from this group, send email to
>> pyglet-users+unsubscribe@googlegroups.com.
>> For more options, visit this group at
>> http://groups.google.com/group/pyglet-users?hl=en.
> I had thought the on_key_press one was to check when a key was pressed > and the update function checked whether a key was held down. Is that > right? :/
> On Fri, Oct 12, 2012 at 4:10 AM, Nathan <nathan.sto...@gmail.com > <mailto:nathan.sto...@gmail.com>> wrote:
> On Wed, Oct 10, 2012 at 9:34 PM, Wallace Davidson
> <wallace...@gmail.com <mailto:wallace...@gmail.com>> wrote:
> Is it possible to have both of these in a program? I have:
> @window.event
> def on_key_press(symbol, modifiers):
> if symbol == key.ESCAPE:
> return pyglet.event.EVENT_HANDLED
> But only the on_key_press function is recognised. Would it be
> better to have one or the other?
> That is certainly possible, you just need to schedule the
> update(dt) function to be called -- it's not an event handler
> that's automatically handling some event like on_key_press(...) is.
> Though as Adam already alluded to, just because it's possible
> doesn't mean it's necessarily the best way to do it.
> ~ Nathan
Personally, I set a flag in on_key_press and unset it in on_key_release.