Jump to content

Tinting a group?


Recommended Posts

I'm trying to apply a tint to the whole of a group, to designate a team.

Instead of creating a spritesheet that includes every sprite corresponding to each team, I'm using a grayscale sprites, putting them in a group, and applying tint to that group.

For some reason, this works perfectly with the "group.alpha" setting, but doesnt with the group.tint setting. The sprites just stay grayscale
Here's my code:

var game = new Phaser.Game(800, 600, Phaser.AUTO, 'row', { preload: preload, create: create, update: update });

// Spritemap Key, spritemap url and JSON file URL
var spriteMap = "main"
var textureURL = 'assets/main.png'
var atlasURL = 'assets/main.json'
var terrainLayer;
var terrain;
var biffinRed;
var army;
var corps;
function preload() { //Preloading...
game.load.atlasJSONHash(spriteMap, textureURL, atlasURL) // Loads Sprite atlas and corresponding file}
     } ;
function create() { // Start of create
// creates Red Army supergroup
biffinRed = game.add.group();
biffinRed.name = "Red SuperGroup";
biffinRed.inputEnableChildren = true,
biffinRed.tint =  0xff0000;
    //inside biffinRed, creates "army group", and assigns properties: 
    army = game.add.group(biffinRed);
    army.spriteMap = 'main';
    army.textureURL= 'assets/main.png';
    army.name = "Red army";

    //inside army, create corps, that houses units array
    corps =  game.add.group(army);
    corps.name = 'Army corps'
    corps =       {units: [
                    {assetName: 'artillery0.png',
                     pos_x: 3,
                     pos_y: 3},
                    {assetName: 'artillery0.png',
                     pos_x: 4,
                     pos_y: 4},
                    {assetName: 'antiair0.png',
                     pos_x: 2,
                     pos_y: 4}

//create sprite inside army group using corps properties.
 army.create(corps.units[0].pos_x*32,corps.units[0].pos_y*32, spriteMap, corps.units[0].assetName);

Sorry for the noobie question, still new to phaser.
Any help greatly appreciated,


Link to comment
Share on other sites


  • Recently Browsing   0 members

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