Search the Community
Showing results for tags 'settexture'.
-
I modified the tween loop examples in v3. I'd like to change the texture when every tween loop finished. But the texture flickers after setTexture(). Am I doing anything wrong? var config = { type: Phaser.WEBGL, width: 800, height: 600, backgroundColor: '#2d2d2d', parent: 'phaser-example', scene: { preload: preload, create: create } }; var game = new Phaser.Game(config); function preload () { this.load.image('block', 'assets/sprites/block.png'); this.load.image('arrow', 'assets/sprites/arrow.png'); } var name = ['block', 'arrow']; var i=0; function create () { var marker = this.add.image(100, 300, 'block').setAlpha(0.3); var image = this.add.image(100, 300, 'block'); this.tweens.add({ targets: image, x: 300, duration: 1000, repeat: -1, onRepeat: function(tween, target){ target.setTexture(name[++i%2]); } }); }
- 1 reply
-
- v3
- settexture
-
(and 1 more)
Tagged with:
-
In the invaders game example, when an invader is killed, an explosion sprite takes its place. There are 30 invaders and 30 explosions in 2 groups. Is this the optimal way to do explosions, or will something like .setTexture() (haven't used it yet) do a better job? alien.kill(); var explosion = explosions.getFirstExists(false); explosion.reset(alien.body.x, alien.body.y); explosion.play('kaboom', 30, false, true); The alien sprite is killed and an explosion one replaces it, until the animation plays. Is this the best way to handle explosions for resource limited devices?
-
- settexture
- group
-
(and 3 more)
Tagged with:
-
Hi, I have 5 sprites and i want to play an animation on its sprite. this is the test Page : http://goldgames.eu/test.html I have this problem only on google chrome. when i am setting texture to sprite[0] and sprite[1] its ok but when i am setting texture to sprite[2] the browser lags. what i am doing wrong ? sorry for my english, its not very good
-
I am loading individual texture images using "new PIXI.AssetLoader" Then later when a user clicks on an image i am changing the image using: " var textureName = PIXI.Texture.fromImage ('images/img.png']); this.setTexture(textureName); " However the "preloaded" image isn't always displaying, and needs to load again... Am I doing something wrong? Thanks