首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在xamarin中创建一个cocossharp项目

在xamarin中创建一个cocossharp项目
EN

Stack Overflow用户
提问于 2016-10-23 02:45:41
回答 1查看 579关注 0票数 2

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

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

我已经创建了一个带有IOS,android和PCL的xamarin.form。

我已经在IOS和Android项目中添加了cocosSharp包

如果我不将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类

代码语言:javascript
复制
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);
        }
      }
   }
EN

回答 1

Stack Overflow用户

发布于 2016-11-10 03:24:15

我自己才弄明白的。确实没有匹配配置文件259的构建。请尝试151:

在解决方案资源管理器中,右键单击解决方案资源管理器中的

  1. 项目,然后单击左侧的

  1. ’。
  2. 将当前配置文件更改为“PCL4.6- Profile151"
  3. Click 'OK'.

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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40195764

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档