2009-06-22 66 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進行播客之前)。