Jump to content

CacheAsBitmap and reuse


Jonny Shaw
 Share

Recommended Posts

Hi all

Im working on a new slot prototype and had a bit of a thought about creating reelstrips to use for different animations, and just wanting a little advice on best approach.


Because I've had problems caching the spines as bitmaps for the reel drops had a different idea to it. 

At the moment I'm using spines for the icons, what I would like to do is have a function that generates a random strip (of any length passed of the icons - add the landing icons to the end of the strip - positioned the same as they would be in the reels, cache it as a bitmap and destroy the icons - then use the animated strip for the animation.

Thought to have the animated icons static and hidden in the reels.  Instead of animating them on the reel drops use the generated reel strips if that makes sense?  This way I can make a robust spin function that can work at different speeds loops etc?  Reason I would rather do it in game rather than manually via photoshop is I can reuse it for different icons, games can tweak and the strips would update to match?  Presume filters would run better as well with this approach rather than directly on spines?

To reuse presuming I would have to save out as a png using canvas to image - or would this idea be way too much overhead?  Also would the pngs then need to be readded to the pixi loader or would they be already accessible somewhere?  It wouldnt be run during the game, only at startup behind the scenes I think.

Just starting out with it now, so any advice greatly appreciated!

 

Link to comment
Share on other sites

Just create a renderTexture and use `renderer.render(myStuff, renderTexture)` many times with different position of stuff, dont forget to update its animations every time. Thus, you'll get your strip in renderTexture. Create many `PIXI.Texture` regions out of it and pass to AnimatedSprite.

Bless you.

Link to comment
Share on other sites

On 12/5/2017 at 2:48 AM, AnDG said:

In my slot games, I usually use the animatedSprite for images on each reel and use TweenMax to make slot effects. Typically, the use of animatedSprite for slot games is much better with using spines.

Thanks yeah, sorry presume you mean animatedSprite is better than using spines there?  We've gone for spine really because the manequin atlas's can be a lot lighter than a 20-30 keyframed animation and mobile is our prime target.  We're also using TweenMax for the reel animation.  We have got something going now with just cacheAsBitmap by rendering the currentIcons + a list of random icons + newIcons which works pretty well, but creating the strip at runtime does delay the spin for a few milliseconds atm, so will see if we can optimise it somehow.

I tried RenderTexture as @ivan.popelyshev suggested which worked to a point, but strangely it was duplicating the reels in the stage (though not on view) when it was sent to the rendererer to create the texture.  Not sure if I was doing something wrong there or if that is the normal behavior and there is somewhere to clear it?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...