2012-12-19 23 views

Trả lời

7

Vì XNA chỉ được hỗ trợ cho các ứng dụng WP7, bạn sẽ phải kiểm tra xem ứng dụng của bạn có đang chạy trên WP8 hay không và nếu có thì hãy sử dụng tính năng phản chiếu để cập nhật biểu tượng cho biểu tượng WP8. Có một ví dụ hay về cách đoạn mã đó trông như thế nào tại bài viết MSDN này @Adding Windows Phone 8 Tile functionality to Windows Phone OS 7.1 apps

Bạn có thể dễ dàng sử dụng thư viện Mangopollo với khả năng tương thích với API tương tự như WP8. Dưới đây là mã nguồn mà kết thúc tốt đẹp các API WP8 để được gọi từ WP7 @http://mangopollo.codeplex.com/SourceControl/changeset/view/100687#2023247

Và đây là đoạn Mangopollo mã để sử dụng gạch rộng WP8 trong các ứng dụng WP7:

if (!Utils.CanUseLiveTiles) 
{ 
    MessageBox.Show("This feature needs Windows Phone 8"); 
    return; 
} 

try 
{ 
    var mytile = new FlipTileData 
    { 
     Title = "wide flip tile", 
     BackTitle = "created by", 
     BackContent = "Rudy Huyn", 
     Count = 9, 
     SmallBackgroundImage = new Uri("/Assets/logo159x159.png", UriKind.Relative), 
     BackgroundImage = new Uri("/Assets/Background336x336_1.png", UriKind.Relative), 
     BackBackgroundImage = new Uri("/Assets/Background336x336_2.png", UriKind.Relative), 
     WideBackContent = "This is a very long long text to demonstrate the back content of a wide flip tile", 
     WideBackgroundImage = new Uri("/Assets/Background691x336_1.png", UriKind.Relative), 
     WideBackBackgroundImage = new Uri("/Assets/Background691x336_2.png", UriKind.Relative) 
    }; 

#if ALTERNATIVE_SOLUTION 
    var mytile = Mangopollo.Tiles.TilesCreator.CreateFlipTile("flip tile", 
    "created by", "Rudy Huyn", 
    "This is a very long long text to demonstrate the back content of a wide flip tile", 
    9, new Uri("/Assets/logo159x159.png", UriKind.Relative), 
    new Uri("/Assets/Background336x336_1.png", UriKind.Relative), 
    new Uri("/Assets/Background336x336_2.png", UriKind.Relative), 
    new Uri("/Assets/Background691x336_1.png", UriKind.Relative), 
    new Uri("/Assets/Background691x336_2.png", UriKind.Relative)); 
#endif 
    ShellTileExt.Create(new Uri("/MainPage.xaml?msg=from%20wipe%20flip%20tile", 
     UriKind.Relative), mytile, true); 
} 
catch 
{ 
    MessageBox.Show("remove tile before create it again"); 
} 

Một điều nữa cần ghi nhớ là khác Các API WP8 có thể được sử dụng trực tiếp từ XNA mặc dù các ứng dụng XNA là các ứng dụng WP7. Dưới đây là ví dụ về cách use WP8 in-app purhcase on WP7 apps (bao gồm XNA). Và đây là một ví dụ về how to use new WP8 Launchers & Choosers in WP7 apps (cuộn xuống).

+0

Câu lệnh cuối cùng của đoạn mã trên từ ứng dụng ví dụ Mangopollo sử dụng Uri của MainPage.xaml để khởi chạy ứng dụng. Những gì Uri nên được sử dụng cho một trò chơi XNA? –

Các vấn đề liên quan