我是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类
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);
}
}
}发布于 2016-11-10 03:24:15
我自己才弄明白的。确实没有匹配配置文件259的构建。请尝试151:
在解决方案资源管理器中,右键单击解决方案资源管理器中的
‘
现在,您需要刷新Nuget包,以便Xamarin表单可以重新下载正确的配置文件。然后,您可以成功地添加CocosSharp.Forms。
https://stackoverflow.com/questions/40195764
复制相似问题