CCSprite not rendering on Android

bittersweet69bittersweet69 GBMember ✭✭

Hi, I'm doing some prototyping with CocossharpView and Xamarin.Forms. I've downloaded the code from here:-

https://developer.xamarin.com/samples/xamarin-forms/CocosSharpForms/

And added the following code to the "MoveCircleLeft" method in the GameScene class:-

_sprite = new CCSprite("Content/ball.xnb");
_mainLayer.AddChild(_sprite);

I have to add the Content/ part of the path otherwise the app hangs (though I do set the GameView content manager root directory to Content). Even so, the sprite is not rendered on the layer. I've spent 2 days, first with my own app and now with the sample app taken from the above link, trying to get a simple sprite to output on the layer. What am I doing wrong?

If I look at the sprite in the debugger everything is 0, ContentSize, Texture dimensions - it's as if it has not loaded the texture. Have tried this with both xnb and png files, both of which are marked as AndroidAsset.

I've added the Content folder to my PCL project and then added a link to this folder in the Assets directory of the Android project. I've been forced to do this as adding the Content folder directly to the Assets folder gives me the following compiler error:-

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets(2,2): Error MSB3025: The source file "Assets/Content/" is actually a directory. The "Copy" task does not support copying directories. (MSB3025) (FormsWithCocosSharp.Droid)

Could someone please let me know why this is proving so difficult for me? I'm testing this app on my Sony Xperia E2303 phone (API 21).

Many thanks, P.

Answers

  • bittersweet69bittersweet69 GBMember ✭✭

    Update: If I change the Build action of the xnb file in the PCL project to be Content then I get a white square output on the layer.

  • FrankZFrankZ USMember

    I had this issue in a completely different context but I also had to add some content to the Android Assets folder. After rearranging the Assets-folder (I have added a new folder and moved some files) there have suddenly been created some "empty directories" (maybe this is a bug of Visual Studio?). After deleted these ghost folders everything was going fine again. Maybe this helps.

Sign In or Register to comment.