Forum Libraries, Components, and Plugins

Spin a slot machine reel

I'm building a slot machine in Cocossharp and was wondering how to make it spin. I did this a while back in flash but can't remember how.



  • lahellerlaheller USMember ✭✭

    Alternative solution:
    Try using UrhoSharp 3D engine.
    Based on doucmentation it is easy to learn, it is lightweight engine, no need to really understand the magic behind 3D.

    One slot would be a main node with child nodes having components of type plane, each with texture of fruit on it.
    Then spinning is only about rotation of main node, i. e. call its .Pitch(degree) method required times.

    Good luck!

  • JoeBonavitaJoeBonavita USMember ✭✭

    I'd hate to switch since we have several other games done in Cocossharp already. I was looking at the CCMaskedSprite but haven't been able to get it to work. I'm pretty sure I need that to mask or hide, the elements that are outside the reel area.

    Can UrhoSharp 3D be used for 2D games as well?

  • lahellerlaheller USMember ✭✭

    Can UrhoSharp 3D be used for 2D games as well?

    I think yes.

  • JoeBonavitaJoeBonavita USMember ✭✭

    Maybe it's just me but I can't figure out the editor...

    I tried my first project. I figured I would copy one of the 2D ones and do it all in code. All I wanted to do was add a background image, however the image is way too big. It's 1080 * 1920. Where do I size the scene?

    I guess this is going to take a little while for me to figure out.

  • lahellerlaheller USMember ✭✭

    There is a Scene editor for Urho3D engine.
    Just download the latest release of Urho3D engine, unpack the zip and start bin\editor.bat.

  • JoeBonavitaJoeBonavita USMember ✭✭

    I can run the editor, I just can't figure out how to use it.

    For example I add a StaticSprite2D, drag a texture to its Sprite property from the Resource browser but the Sprite is never visible.

  • utekaiutekai USMember ✭✭✭

    Adding a sprite in code is fairly quick and easy. There are various samples showing it.

  • JoeBonavitaJoeBonavita USMember ✭✭

    It seems easy but in my case, I added sprites through code and some appear behind their parent. I can't figure out why since all the code is the same.
    To fix one sprite, all I did was open the png file photoshop and resave it and it fixed the problem. This, of course, makes no sense.

    I figured out the editor (somewhat) so I'm going to try and create the same scene with the same images and see what happens.

  • utekaiutekai USMember ✭✭✭

    Not sure what you mean that some are behind parent?

    There are many working samples you can see with just a click at The code for those samples is in c++ but it's easy to read and convert to c# with urhosharp knowledge and seeing the urhosharp feature samples that originated from those c++ samples, but frankly the c++ samples are better as the urhosharp samples were done in a hurry and not faithful to the original in many cases.

    The sprites are initially placed using this:

    spriteNode.Position = (new Vector3(NextRandom(-halfWidth, halfWidth), NextRandom(-halfHeight, halfHeight), 0.0f));

    You could add different depths by using an appropriate value for Z other than 0.0f.

    If you're dealing with two items at the same depth location, then you adjust the depthBias, for example with decals, here's some code that does it:

    depthBias -= 0.000001f; //so each subsequent decal will be topmost
    decal.Material.DepthBias = new BiasParameters(depthBias, 0f, 0f); //for z-bias flicker

    What you want to accomplish as far as I understand it, is truly trivial. You're just struggling from a beginner's stance. If you run several samples, without regard to what you want to accomplish, but in order to learn a bit about the urho3d engine, you'll get it done much faster. Learn several samples and the rest will be easy.

  • JoeBonavitaJoeBonavita USMember ✭✭

    @utekai Would you be interested in creating the scene for me for a fee?

Sign In or Register to comment.