TM.DebugManager

View source code: https://github.com/a-mean-blogger/text-game-maker-js/blob/master/src/managers/debug-manager/debug-manager.js

Type

Class (extends TM.IObject)

Purpose

A class that creates instances print debugging data on the browser.

Constructor Parameters

new TM.DebugManager(debugSetting)
  • customSreenSetting(optional): an object that will be used to create the instance overriding the values of TM.defaultSettings.debug. It does not print debugging data by default, so {devMode:true} should be passed to print them.

Important Properties

  • isActive: It will be set true after calling init function, false after calling inactivate. The Object status(active/inactive) can be checked by this property.

Important Functions

  • init(): activates/initializes the instance. (It executes when the instance created)
  • inactivate(): inactivates the instance. It will not print debugging data anymore.

Functions related to debugging

  • print(name,data): print name(text) and data(object) on the browser.
  • delete(name): delete debugging data of name on the browser.
  • deleteAll(): delete all debugging data on the browser.

Code Example

**View example source code: debug-manager-tutorial.js

First, create an instance of TM.ScreenManager and assign to var TMS(Text Game Maker Screen) and then First, create an instance of TM.DebugManager and assign to var TMD(Text Game Maker Debugging).

var TMS = new TM.ScreenManager(),
    TMD = new TM.DebugManager({devMode:true});

Create an instance of TM.Interval that creates current time and print on the screen with 1000 milliseconds interval. adding TMD.print function to print data.

var myWatch = new TM.Interval(1000,function(){
  var date = new Date();
  TMS.insertTextAt(1,1,date.toLocaleTimeString());
  TMD.print("watchData",{date:date});
})
myWatch.init();

Run Example

 

The debugging data is showing right side of Screen.

Type these commands into the browser console on this page to test.

//inactivate TMD 
TMD.inactivate();

//re-activate(initialize) TMD
TMD.init();

Comments

Add Comment

Login with SNS account to write comments. see details

UP