首页 > 其他 > 详细

context configure and clock schedule

时间:2015-06-20 22:01:01      阅读:342      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!