码迷,mamicode.com
首页 > 其他好文 > 详细

context configure and clock schedule

时间:2015-06-20 22:03:37      阅读:201      评论:0      收藏:0      [点我收藏+]

标签:

每个窗口都有自己的context,这里演示怎么配置context以及如何实现定时器......

 #-*- coding:gbk -*-
import pyglet

platform=pyglet.window.get_platform()
display=platform.get_default_display()
screen=display.get_default_screen()

template=pyglet.gl.Config(alpha_size=8)
config=screen.get_best_config(template)
context=config.create_context(None)
window=pyglet.window.Window(context=context)

image=pyglet.image.load(splash.png)
sprite=pyglet.sprite.Sprite(image)
sprite.dx=10.0

@window.event
def on_draw():
    """
    draw the window and widget
    """
    window.clear()
    sprite.draw()

def update(dt):
    """
    update  every 1/60.0 seconds
    """
    sprite.y+=sprite.dx*dt
    sprite.x+=sprite.dx*dt
pyglet.clock.schedule_interval(update,1/60.0)

pyglet.app.run()

 

context configure and clock schedule

标签:

原文地址:http://www.cnblogs.com/yinwei-space/p/4591015.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!