【问题标题】:create a cocossharp project in xamarin在 xamarin 中创建一个 cocossharp 项目
【发布时间】:2016-10-22 18:45:40
【问题描述】:

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

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 studio V6,请问我该如何解决?

或者我怎样才能像以前版本的 xamarin 一样在 Galery 中添加 cocosSharp 的插件?

这是一个ContentPage中的代码,找不到Cocos Classes

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

【问题讨论】:

    标签: c# xamarin-studio cocossharp


    【解决方案1】:

    只是我自己想通了。确实没有与 Profile 259 匹配的版本。请尝试使用 151:

    1. 在解决方案资源管理器中右键单击 PCL 项目
    2. 点击“选项”
    3. 点击左侧的“常规”。
    4. 将当前配置文件更改为“PCL 4.6 - Profile151”
    5. 点击“确定”。

    现在您需要刷新 Nuget 包,以便 Xamarin Forms 可以重新下载正确的配置文件。之后就可以成功添加CocosSharp.Forms了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-02-02
      相关资源
      最近更新 更多