Jump to content

New sprite from multiple sprites


erest0r
 Share

Recommended Posts

Hello, i need some help to avoid loading a large number of sprites, my game uses blocks, but they look at various direction (UP, RIGHT, DOWN, LEFT, UP_RIGHT, UP_DOWN, UP_RIGHT_DOWN and so on) as you can see, there are pleny of combinations, 16 in total, but i have blocks of 4 differents color so, i would have 16 x 4 = 64 sprites, i know i can use spritesheets, the thing is i would like to have only: BLUE, RED, YELLOW GREEN, UP, DOWN, LEFT, RIGHT (8 total sprites), i'm trying to look what object in Phaser can combine multiple sprites into a new one, example, something like this:

 

var my_new_sprite = Phaser.addSprites(['blue', 'right', 'down']);

So, "my_new_sprite" would be a block with a combination of "blue, right, down" sprites.

Link to comment
Share on other sites

51 minutes ago, erest0r said:

Hello, i need some help to avoid loading a large number of sprites, my game uses blocks, but they look at various direction (UP, RIGHT, DOWN, LEFT, UP_RIGHT, UP_DOWN, UP_RIGHT_DOWN and so on) as you can see, there are pleny of combinations, 16 in total, but i have blocks of 4 differents color so, i would have 16 x 4 = 64 sprites, i know i can use spritesheets, the thing is i would like to have only: BLUE, RED, YELLOW GREEN, UP, DOWN, LEFT, RIGHT (8 total sprites), i'm trying to look what object in Phaser can combine multiple sprites into a new one, example, something like this:

 


var my_new_sprite = Phaser.addSprites(['blue', 'right', 'down']);

So, "my_new_sprite" would be a block with a combination of "blue, right, down" sprites.

You need to use bitmapdata. You make the bmd then you use it as you would use a normal image as spritesheet.

https://jsfiddle.net/1gqwaknd/

https://jsfiddle.net/1gqwaknd/2/ - with animation

http://phaser.io/examples/v2/category/bitmapdata

http://phaser.io/examples/v2/sprites/spritesheet

Link to comment
Share on other sites

1 hour ago, tips4design said:

What do you mean by "combination" ? Is the resulted sprite an existent image or you generate it by combining a "blue" block with a  "right" block? 

If you overlap them, try adding them in a group.

Overlaping would be many sprites loaded for a single block. I think the solution provided by @symof is what i was looking for. I will try that. Thanks.

 

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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