Jump to content

image + test in "container"


Rafus
 Share

Recommended Posts

Hi, 

I'm new in pahser and in js ;)

 

I'm making an easy game - something like "memory game" it will be easy to place just images that you have to find,

but i need to place text on image and animate both.

in flash :P i create mc and animate him,

Have can i do this in phaser?

Link to comment
Share on other sites

There are a couple of ways, but probably best would be to use the approach I use in the Tanks demo game. It's in the dev branch on github, but basically creates a "Tank" object which consists of a few different sprites - which in your case would be a card image and the text. But anyway if you checkout the dev branch and look in examples/games/tank.js you'll see how I do it.

Link to comment
Share on other sites

Thanks for the info.

This is the way you did it:

Creating tank:

var tank;	tank = game.add.sprite(0, 0, 'tank', 'tank1');tank.anchor.setTo(0.5, 0.5);tank.animations.add('move', ['tank1', 'tank2', 'tank3', 'tank4', 'tank5', 'tank6'], 20, true);

now adding turret on top

turret = game.add.sprite(0, 0, 'tank', 'turret');

My code is something like;

this.bunny =  this.game.add.sprite(0,0,"bunny");this.bunny.inputEnabled = true;this.bunny.pixelPerfect = true;this.bunny.input.enableDrag(false,false,true,false,this);this.bunny.input.useHandCursor = true;var t = "Test";var style = { font: "65px Arial", fill: "#000000", align: "center" };this.text = this.game.add.text(0, 0, t, style,'bunny');and now i was trying to move baunny and.. nothing. 

Is it correct?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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