parent = game.add.sprite(100, 100, 'disk'); child = game.make.sprite(0, 0, 'ball'); parent.addChild(child); // Fix the scale of the child so it will never scale below 1 or above 2 child.setScaleMinMax(1, 2); // Even though the parent will scale, the child will remain at its own scale (and this is carried on down to any of its children) game.add.tween(parent.scale).to( { x: 3, y: 3 }, 2000, Phaser.Easing.Linear.None, true, 0, 1000, true);
10. 圆形遮罩
1 2 3 4 5 6 7 8 9 10 11 12
//Here we add a Sprite to the display list sprite = game.add.sprite(0, 0, 'chaos'); sprite.scale.set(2); //创建遮罩形状 mask = game.add.graphics(0, 0); //填充 mask.beginFill(0xffffff); mask.drawCircle(100, 100, 100); sprite.mask = mask; //移动鼠标或遮罩时 game.input.addMoveCallback(move, this); move:mask.x = x - 100;mask.y = y - 100;
// 创建bitmap var bmd = game.add.bitmapData(128,128); // draw to the canvas context like normal bmd.ctx.beginPath(); bmd.ctx.rect(0,0,128,128); bmd.ctx.fillStyle = '#ff0000'; bmd.ctx.fill(); var sprite = game.add.sprite(200, 200, bmd);