Jump to content

attaching a text with sprite image and making the text able to tween with sprite image

Manikant tiwari

Recommended Posts

I am very new to phaser. I am creating a game with phaser 2.x. I want to apply tween on text along with the sprite which is parent of the text, because I have made text as a child of the sprite image.

I have tried with the following code.

var GameState = {
        this.load.image('blackboard', 'assets/images/ticket2.jpg')
        this.load.image('arrow', 'assets/images/arrow.png')
        this.blackboard = this.add.sprite(this.game.world.centerX, 525, 'blackboard');

        this.arrow = this.add.sprite(40, 370, 'arrow')
        this.arrow.inputEnabled = true;
        this.arrow.events.onInputDown.add(this.showBlackboard, this)
  showBlackboard: function () {
        var whiteStyle1 = { font: "25px Arial", fill: "#ffffff" }
        this.one = this.add.text(120,280,"1",whiteStyle1);
        var tween = this.add.tween(this.blackboard);
        tween.to({ y: 350 }, 500)

Only the blackboard is being tweened. Even the text is not being printed on the screen. Can anybody give me a solution please

Link to comment
Share on other sites


  • Recently Browsing   0 members

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