Forum Libraries, Components, and Plugins

Is CocosSharp adapted for these specific needs?

Hello,

After exchanging with the Xamarin support, I was advised to use CocosShparp for porting a WPF application. But before we engage in extensive testing, I wanted to know the user reviews to find out if it's really suitable.

The current version of WPF software is a soccer drills editor, based on a full library of players, goalkeepers and accessories. The users can also add shapes and text:

One of the most important element of our software is so the library: for the WPF application, we have developed a tool that create an encrypted DLL which containing all images. For optimizing the occupied space, this tool gathers the images by “position” on a big sheet of pictures:

So in our software, a specific position is identified by its name and its coordinates in this sheet
=> But how to create, store and "protect" an images library with CocosSharp?

To build an exercice, the user must first define the background image, and then drag&drop different type of elements: images from the library, shapes or text areas,... So there is a drag&drop between the library "area" and the exercice "area", but the user must also be avaliable to move the element after drag&drop to adjust its position on the field.
=> Is this easily feasable with CocosSharp?

In addition, we also need that some images could be "recolorable": we have defined a default color (cyan) for these images, and the user can modify it in the app: this is done by the code.

=> Could we do something like this with CocosSharp?

Thanks a lot for your returns and feedbacks...

Answers

  • RamiTabbaraRamiTabbara AUMember, Xamarin Team Xamurai

    Hi Pierre,

    Firstly, I'm assuming that you want to port the WPF application to mobile (iOS, Android, Windows Phone)? If this is the case, then I believe the combination of Xamarin.Forms and CocosSharp could achieve what you're after.

    Specifically, you could create a Xamarin.Forms application that would be responsible for housing all the controls of your application (i.e. the library, tool options etc.). I'm not too sure whether you're familiar with Xamarin.Forms — if not, please check out this introductory guide here. But in general, Xamarin.Forms includes controls such as ListViews, so I'm confident that you could setup your interface to provide the same functionality.

    A CocosSharpView would then be included to render the actual soccer drill exercise. A good reference guide describing how to set this up can be found here.

    With respect to your specific questions:

    • Drag and drop between library and in-game: You can certainly setup the CocosSharp game so that you can drag and re-position elements within the actual game view. Dragging elements from the library into the game (exercise area) may not be as straight-forward. However, if this is indeed for mobile, given the limited screen space, I would think that the library itself would not be visible at the same time as the exercise area . Instead you could use a MasterDetail page, as seen below

    image

    as a way of hiding and showing the library elements only when they are needed.

    • Create, store and "protect" an image library with CocosSharp CocosSharp provides support for sprite-sheets (i.e. the stack of images of a player at different angles), so storing and reading these within your application shouldn't be a problem.

    • Recoloring of images CocosSharp has support for dynamic textures, so again recoloring your images should also be possible.

    Finally, before you make the plunge, please be aware of a few things:

    1) A current limitation of CocosSharpView is that you can only have one active view at any one time. That means, that for instance, if you wanted to have multiple exercise areas rendered at the same time, then you would be out of luck.

    2) What you didn't really describe is whether or not there are any interactive elements within the exercise area. For instance, is there a play/pause/stop feature so that a user simulate players and the ball moving for a given scenario? Or is everything in the exercise area static and never moves (aside from a user dragging to re-position)? In either case, CocosSharp should be able to accommodate for the intended use cases.

    Hope that helps!

  • JonDavisJonDavis USMember ✭✭

    Rami's answer is awesome. I wanted to link to my open source Xamarin.Forms & CocosSharp game, @Pierre-ChristopheDus to use as an additional reference.

  • Victor.ChelaruVictor.Chelaru USMember, Xamarin Team Xamurai

    To add to Rami's answer, we also have a recipe covering sprite recoloring which doesn't require creating dynamic textures. If your original art is set up right (usually grayscale) then you can take advantage of the CCSprite.Color property:

    https://developer.xamarin.com/recipes/cross-platform/game_development/sprite_color/

  • PacodosoPacodoso FRUniversity ✭✭✭

    Thanks for your returns!

    @RamiTabbara
    For answering to your questions:

    Firstly, I'm assuming that you want to port the WPF application to mobile (iOS, Android, Windows Phone)?

    Actually, we think develop 2 versions:

    • the equivalent of our WPF application for tablets
    • a "viewer" version for smarpthones, as we think that these devices are not really adapted

    What you didn't really describe is whether or not there are any interactive elements within the exercise area. For instance, is there a play/pause/stop feature so that a user simulate players and the ball moving for a given scenario? Or is everything in the exercise area static and never moves (aside from a user dragging to re-position)?

    In the first version, everything will be static, as in our WPF application. But we also plan to make the dynamic elements in a future release.
    => Does the share of work to make it dynamic is really important?

    I would also have clarification in relation to one of your comments:

    A current limitation of CocosSharpView is that you can only have one active view at any one time. That means, that for instance, if you wanted to have multiple exercise areas rendered at the same time, then you would be out of luck.

    => Does that mean that we couldn't show the list of the items in a CocosSharp View through a MasterDetail page, and drag&drop a selected item in the main area that must also be a CocosSharp View?

    @JonDavis
    Thank you, I've downloaded your sample: it allows me to study a basic integration between Xamarin.Forms and CocosSharp.

    @VictorChelaru @RamiTabbara
    About dynamic textures or CCSprite.Color, I think that our images are not adapted: for example for the players, for the players, we only want to change the color of the shirts and socks. The rest of the picture (head, arms, legs, shorts) should not be affected. That's why we do a coloring by code in our applicaiton WPF, by applying it only to the "cyan" areas of the image.

    => What do you think about this problem?

  • VictorChelaruVictorChelaru USMember ✭✭

    For situations like that, I recommend using mulitple sets of images. You could have one set of images which will not change color (the skin, shoes, possibly the pants), and then you could have another image which has the shirt as grayscale. The object in CocosSharp would use 2 sprites, one using the first image, the other using the second image. Only the second sprite would be colored, effectively letting you change the shirt color without changing anything else.

  • PacodosoPacodoso FRUniversity ✭✭✭

    @VictorChelaru
    I see...
    Does that mean that we need to use 2 Sprite Sheets : 1 containing the skin and 1 containing the recoloriable items?
    For this, each associated item in the 2 Sprite Sheets must have the same size, even if it contains a lot of "empty space".
    Can we do this easily?
    What is the better approach for us? We need to develop a tool that will "separate" the layers of each image?

  • VictorChelaruVictorChelaru USMember ✭✭

    Yes, that's the approach I would take, so long as there isn't too much wasted space - or more importantly - so long as you aren't running out of space for your app. I've shipped games which use a few 2048x2048 textures and haven't had any problems. It all depends on how much content your app is using, and if all of the content is needed at once, or if it can be unloaded intelligently when no longer being used.

Sign In or Register to comment.