Changing prefab sprite frame not working on Android

Hi

I’m instantiating a number of ‘bubbles’ inside a loop in my Game script. The bubble prefab is linked to a BackgroundNode script component. In the spawn method of BackgroundNode, I pick a random colour image and update the sprite frame.

Running in browser I see bubbles with different colour sprite frames, but running on Android there is only 1 colour sprite frame (the same colour as is configured in Cocos Creator).

Am I doing this wrong?
Is there any way I can achieve this without having a prefab for every colour?

Thanks
FT

Game.js

var bubble = cc.instantiate( this.bubblePrefab );
this.node.addChild( bubble );
bubble.getComponent( 'BackgroundNode' ).spawn( true );

BackgroundNode.js

var textureUrl = '/path/to/image.png';
var texture = cc.textureCache.addImage( textureUrl );
var sprite = this.node.getComponent( cc.Sprite );
var spriteFrame = new cc.SpriteFrame( texture, sprite.spriteFrame.getRect() );
sprite.spriteFrame = spriteFrame;
1 Like