Sign in to follow this  
Manikant tiwari

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

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 = {
  preload:function(){
        ---------
        this.load.image('blackboard', 'assets/images/ticket2.jpg')
        this.load.image('arrow', 'assets/images/arrow.png')
        ---------
  }
  create:function(){
    ------
        this.blackboard = this.add.sprite(this.game.world.centerX, 525, 'blackboard');
        this.blackboard.anchor.setTo(0.5)

        this.arrow = this.add.sprite(40, 370, 'arrow')
        this.arrow.anchor.setTo(0.5)
        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);
        this.blackboard.addChild(this.one);
        var tween = this.add.tween(this.blackboard);
        tween.to({ y: 350 }, 500)
        tween.start();
  }
}

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

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.