Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

equivalent createjs code for dynamic as3 text

Contributor ,
Feb 12, 2016 Feb 12, 2016

/* js

var hitBool=true;

var score=0;

var txt = new createjs.Text("Game Over", "20px Arial", "#ff7700");

txt.textBaseline = "middle";

txt.textAlign = "center";

txt.x = stage.canvas.width / 2;

txt.y = stage.canvas.height / 2;

addEventListener('tick', checkCollision);

function checkCollision() {

  // test star versus crescent

  if (star.hitTest(crescent)) {

if(!hitBool){

hitBool=true;

  score=score+1;

  txt.text=score.toString();

    stage.addChild(txt);

stage.update();

}

  } else {

hitBool=false;  // <- if you want to allow another hit after a no-hit.

  }

}*/

but the code is not working . how can i make createjs text field dynamic for game scoring ? is there any easier way ? in flash we have easier option to create dynamic text field . i want dynamic not displaying text .

dynamic.jpg

// as3 code

var hitBool:Boolean

var score:Number=0;

addEventListener(Event.ENTER_FRAME, checkCollision);

function checkCollision(event:Event) {

  // test star versus crescent

  if (star.hitTestObject(crescent)) {

if(!hitBool){

hitBool=true;

  score=score+1;

  text1.text=String(score);

}

  } else {

hitBool=false; 

  }

}

TOPICS
ActionScript
894
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Contributor , Feb 13, 2016 Feb 13, 2016

ok. i could do it myself

flash cc export dynamic text automatically for createjs

for more understanding this link

dynamic text in createjs | Graphicscoder

Translate
Contributor ,
Feb 13, 2016 Feb 13, 2016
LATEST

ok. i could do it myself

flash cc export dynamic text automatically for createjs

for more understanding this link

dynamic text in createjs | Graphicscoder

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines