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

Create a counter in AS3

New Here ,
Mar 19, 2015 Mar 19, 2015

Hi I am busy building an escape the room type game where the user must find 6 items in a room before they can leave the room.  I have almost build the room however I want to include a counter that displays how many items have been found.  So when a item is found on the stage the counter would increase by one until a target is reached at which point the user would be able to exit the room.  Any ideas how i would code this counter??

TOPICS
ActionScript
293
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

Community Expert , Mar 19, 2015 Mar 19, 2015

it looks like this:

itemNum++;

Translate
Community Expert ,
Mar 19, 2015 Mar 19, 2015

assign a variable to track the items and initialize it to zero when a room is entered (if that's what you want):

var itemNum:int = 0;

increment the counter when an item is found:

itemNum++;

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
New Here ,
Mar 19, 2015 Mar 19, 2015

I have created the variable and set to 0.  However i'm not sure how to get it to add one when an item on the stage is clicked on??  What would this look like??  Any help would be great

Thanks in anticipation

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
Community Expert ,
Mar 19, 2015 Mar 19, 2015
LATEST

it looks like this:

itemNum++;

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