在xamarin中创建一个cocossharp项目 [英] create a cocossharp project in xamarin

查看:91
本文介绍了在xamarin中创建一个cocossharp项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是xamarin Studio中的新手,并且正在尝试按照官方指南创建cocosproject,但是此文档不太清楚,我的项目有很多错误.

Im new in xamarin studio and im trying to create a cocosproject following the official guide, but this document is not very clear and my project have so many errors.

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

我已经按照IOS,android和PCL的指导创建了一个xamarin.form

I've created a xamarin.form with IOS, android and PCL as guide say

我已将cocosSharp软件包添加到IOS和Android项目中

I've added the cocosSharp packages to IOS and Android projects

但是

如果我未将cocosSharp软件包添加到PCL目标,则无法通过代码找到cocos类

if i don't add the cocosSharp package to PCL target, the cocos Classes cant be found by the code

如果我尝试将cocosSharp软件包添加到PCL,请通过控制台显示

And if I try to add the cocosSharp packages to PCL, console show this

无法安装软件包"CocosSharp 1.7.1".您正在尝试将此软件包安装到以'.NETPortable,Version = v4.5,Profile = Profile259'为目标的项目中,但是该软件包不包含任何与该框架兼容的程序集引用或内容文件.有关更多信息,请与程序包作者联系.

Could not install package 'CocosSharp 1.7.1'. You are trying to install this package into a project that targets '.NETPortable,Version=v4.5,Profile=Profile259', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author.

我试图更改targetFramework,但这对我没有帮助

i tried to change the targetFramework but this don't help me

如果有人使用cocosSharp和xamarin Studio V6,请问我该如何解决?

if someone work with cocosSharp and xamarin studio V6, please how can i solve this ?

或者我如何像以前的xamarin版本一样在Galery中添加cocosSharp的添加项?

Or how can i add the add in of cocosSharp in Galery like in previous versions of xamarin ?

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

This is the code in a ContentPage, Cocos Classes can't be found

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

推荐答案

我自己才知道.确实没有针对Profile 259的匹配版本.请尝试151:

just figured this out myself. It's true that there's no matching build for Profile 259. Try 151 instead:

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

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

Now you'll need to refresh the Nuget Packages so that Xamarin Forms can redownload the right profile. Afterward you can successfully add CocosSharp.Forms.

这篇关于在xamarin中创建一个cocossharp项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆