Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 在xamarin中创建cocossharp项目_C#_Xamarin Studio_Cocossharp - Fatal编程技术网

C# 在xamarin中创建cocossharp项目

C# 在xamarin中创建cocossharp项目,c#,xamarin-studio,cocossharp,C#,Xamarin Studio,Cocossharp,我是xamarin studio的新手,我正试图按照官方指南创建一个合作项目,但是这个文档不是很清楚,我的项目有很多错误 我用IOS、android和PCL创建了一个xamarin.form 我已经将cocosSharp包添加到IOS和Android项目中 但是 如果我不将cocosSharp包添加到PCL目标,代码将找不到cocos类 如果我尝试将cocosSharp包添加到PCL,控制台将显示以下内容 无法安装程序包“CocosSharp 1.7.1”。您正试图将此软件包安装到以“.NET

我是xamarin studio的新手,我正试图按照官方指南创建一个合作项目,但是这个文档不是很清楚,我的项目有很多错误

我用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 studio V6,我如何解决这个问题

或者,我如何在Galery中添加cocosSharp的外接程序,就像以前版本的xamarin一样

这是ContentPage中的代码,找不到Cocos类

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);
        }
      }
   }

我自己就知道了。确实没有与Profile259匹配的构建。试试151:

  • 右键单击解决方案资源管理器中的PCL项目
  • 单击“选项”
  • 单击左侧的“常规”
  • 将当前配置文件更改为“PCL 4.6-配置文件151”
  • 单击“确定”
  • 现在需要刷新Nuget包,以便Xamarin表单可以重新下载正确的配置文件。之后,您可以成功添加CocosSharp.Forms