2009-06-22 70 views
0

问候朋友,CoreAnimation Game - 添加视频提要作为背景?

我想覆盖我正在quicktime(.mov)电影顶部开发的简单的2D游戏。我没有这方面的经验(或者很多游戏编程xp),所以我想知道是否有人必须事先处理这个问题,如果是的话,你是如何解决这个问题的?

我一直在研究QuickTime API(QTKit),它看起来很有前途,但如果有更好的方法 - 可以扩展以支持现场视频流,那将是惊人的。

游戏对游戏对象使用CoreAnimation图层,并且当前有一个图像作为窗口背景。所以基本上,我需要将该图像转换为电影。谢谢大家,我感谢您的帮助和建议。

// < Mr. Buffalo > 

回答

0

昨天我在某个时间点想到了这一点。其实很简单。但是,我没有看过成视频流尚未..

的ApplicationController:

- (void) setupQTMovieLayer 
{ 
    // Get the movie and make it loop (my test canned video is short so I loop it) 
    QTMovie * movie = [QTMovie movieNamed:@"Sample.mov" error:nil]; 
    [movie setAttribute: [NSNumber numberWithBool:YES] forKey:QTMovieLoopsAttribute]; 

    // Create the movie on the (CALayer) backgroundLayer, make it sexy, and add it to our view atIndex:0 
    // note: backgroundLayer is a property of this class 
    backgroundLayer = [QTMovieLayer layerWithMovie:movie]; 
    backgroundLayer.masksToBounds = YES; 
    [[contentView layer] insertSublayer:backgroundLayer atIndex:0]; 

    // Goto the beginning and play the movie 
    [movie gotoBeginning]; 
    [movie play]; 
} 
0

我以前没有做过这样的事情,但看看QTMovieLayer

...如果还有更好的方法 - 可以扩展以支持现场视频流,那将是惊人的。

QuickTime已经支持直播流。 (苹果的主题演讲过去是流式传输,在他们转而通过iTunes Store进行播客之前)。