2016-10-22 62 views
2

我在xamarin studio中創建了一個新項目,並試圖根據官方指南創建一個cocosproject,但是這個文檔不是很清楚,我的項目有太多錯誤。在xamarin中創建一個cocossharp項目

https://developer.xamarin.com/guides/xamarin-forms/advanced/cocossharp/#nuget

我已經創建了IOS,Android和PCL一xamarin.form爲指導說

我已經添加了cocosSharp包IOS和Android項目

如果我不添加cocosSharp軟件包到PCL目標,則不能通過代碼找到cocos類

而且如果我嘗試添加cocosSharp軟件包到PCL,控制檯顯示這個

無法安裝軟件包'CocosSharp 1.7.1'。您正在嘗試將此軟件包安裝到以'.NETPortable,Version = v4.5,Profile = Profile259'爲目標的項目中,但該軟件包不包含任何與該框架兼容的程序集引用或內容文件。有關更多信息,請聯繫軟件包作者。

我試圖改變targetFramework但這不幫我

如果有人cocosSharp和xamarin工作室V6工作,請我怎樣才能解決這個問題?

或者我如何在Galery中加入cocosSharp,就像之前版本的xamarin一樣?

這是在ContentPage代碼,科科斯類無法找到

public class MyPage : ContentPage 
{ 
    public MyPage() 
    { 
     Content = new StackLayout 
     { 
      Children = { 
       new Label { Text = "Hello ContentPage" } 
      } 
     }; 
    } 

    void CreateTopHalf(Grid grid) 
    { 
     // This hosts our game view. 
     var gameView = new CocosSharpView() 
     { 
      // Notice it has the same properties as other XamarinForms Views 
      HorizontalOptions = LayoutOptions.FillAndExpand, 
      VerticalOptions = LayoutOptions.FillAndExpand, 
      // This gets called after CocosSharp starts up: 
      ViewCreated = HandleViewCreated 
     }; 
     // We'll add it to the top half (row 0) 
     grid.Children.Add(gameView, 0, 0); 
    } 

    void HandleViewCreated(object sender, EventArgs e) 
    { 
     var gameView = sender as CCGameView; 
     if (gameView != null) 
     { 
      // This sets the game "world" resolution to 100x100: 
      gameView.DesignResolution = new CCSizeI(100, 100); 
      // GameScene is the root of the CocosSharp rendering hierarchy: 
      gameScene = new GameScene(gameView); 
      // Starts CocosSharp: 
      gameView.RunWithScene(gameScene); 
     } 
     } 
    } 

回答

0

只是想通了這一點自己。這是真的,有沒有配套建立檔案259嘗試151來代替:

  1. 右鍵單擊PCL項目在解決方案資源管理器中
  2. 點擊「選項」
  3. 點擊「常規」的左側。
  4. 將當前配置文件更改爲「PCL 4.6 - Profile151」
  5. 單擊「確定」。

現在您需要刷新Nuget Packages,以便Xamarin Forms可以重新下載正確的配置文件。之後,您可以成功添加CocosSharp.Forms。

相關問題