问候朋友,

我正试图在快速时间(.mov)电影上覆盖我正在开发的简单2D游戏。我没有这方面的经验(或许多游戏编程xp)所以我想知道是否有人不得不在此之前处理这个问题,如果是的话,你是如何解决它的?

我一直在研究QuickTime API(QTKit),它看起来很有前景,但如果有更好的方法 - 可以扩展以支持实时视频流,那就太棒了。

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

// < Mr. Buffalo >
有帮助吗?

解决方案 2

我昨天在某个时候想到了这一点。实际上很直接。但是,我还没有看过流视频..

的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];
}
scroll top