Global

Methods

combineTwoNumbers(a, b) → {Number}

Bitwsie combine two numbers. Use tabagos.getAFromCombined and tabageos.getBFromCombined to get the numbers back.

Parameters:
Name Type Description
a Number

The first number

b Number

The second number

Returns:
Type
Number

getAFromCombined(num) → {Number}

Returns the first number in a bitwise combined number pair.

Parameters:
Name Type Description
num Number

The bitwise combined number pair.

Returns:
Type
Number

getBFromCombined(num) → {Number}

Returns the second number in a bitwise combined number pair.

For example, var combined = tabageos.combineTwoNumbers(1,27) var twentySeven = tabageos.getBFromCombined(combined)

Parameters:
Name Type Description
num Number

The bitwise combined number pair.

Returns:
Type
Number

loadSpriteSheetAndStart(img, w, h, start)

tabageos.loadSpriteSheetAndStart

Loads a sprite sheet and then dispatches the given start function. The sprite sheet loaded becomes the tabageos.GameSkeleton.__sprites offscreen CanvasObject. You can streamline the loading of your sprite sheet using this method. These are the steps for streamlining:

  1. Turn your sprite sheet into a base64 string (without the 'data:image/base64,' intro part)
  2. Use the tabageos.stringSplitter method on the base64 string to split it into up to 10 parts.
  3. tabageos.GameSkeleton._str is a static Array ready to hold the parts. Place each part in order into tabageos.GameSkeleton._str. For example; tabageos.GameSkeleton._str[1] = "asdfakjhglwehgrlsabc..." tabageos.GameSkeleton._str[3] = "asldjhgasldyasgtd...."; and so on for each of your parts. They need to be in order but you dont have to start with index 0 and you can skip indexes.
  4. With those three steps done, when you call this method your sprite sheet gets constructed pixel by pixel into tabageos.GameSkeleton.__sprites, instead of being loaded as a file. If your using the GameSkeleton Class then pass "streamline" as the specs.spriteSheetImage value if your going to streamline using this method. And then inside of your start method passed to this function is when you would contruct your new GameSkeleton extension.

If you want to do it yourself, or realize the fullness of what is happening during streamlining, the following otherwise undocumented methods are what are being used: tabageos.GameSkeleton.__baseToCol turns a base64 (stored as parts in tabageos.GameSkeleton._str) string into an array of rgba color values using PNG-JS which is built into the tbgs_min release. and then it calls tabageos.GameSkeleton.__buildColors which uses the color values to construct the CanvasObject pixel by pixel.

Streamlining is a memory intensive process, if your sprite sheet is very large you may not be able to rely on streamlining working on low end devices. For best results your sprite sheet should be 2k to 4k width and height or less and less than 1MB as a .png.

Parameters:
Name Type Description
img String

The file to load, include the full path if its not in the same location as the game index. If you are going to streamline your spritesheet this would be a dummy file, loading your file here and streamlining defeats the purpose of streamlining.

w Number

The width of your sprite sheet

h Number

The height of your sprite sheet

start function

An event handler method to call when loading is complete. A "GameSkeleton" event will happen on the window when loading is complete and your start method will be the handler.

ResizeGame(gameWidth, gameHeight, divideScaleXBy, divideScaleYBy, container, controller, showController, controllerStyle, dontPositionController, cW, cH, camera, cmScaleX, cmScaleY)

Scales the game based on window.innerWidth/Height and gameWidth/Height

Parameters:
Name Type Description
gameWidth Number

the width of game game

gameHeight Number

the height of the game

divideScaleXBy Number

amount to divide the x scale by (1.0 to 1.9)

divideScaleYBy Number

amount to divide the y scale by (1.0 to 1.9)

container HTMLElement

optional reference to the container div element that holds the game and controller canvas element if null is passed no resizing happens

controller HTMLCanvasElement

reference to the controller canvas element (container through the end are optional params)

showController Boolean
controllerStyle Number

1 = 'basicController', 2 = 'directionalsController' or you can pass your own String. sets the controllers canvas elements style id. (see ControllerPad.css and ControllerPad.show())

dontPositionController Boolean

optional if you have placed the controller in your own specific way. Otherwise the controllers canvas elements style top will be set as controller.y and the left as controller.x.

cW Number

controller width - default is 640

cH Number

controller height - default is 192

camera BasicCamera

optional reference to the camera, if not passed only the container gets scaled, generally you don't need to scale the camera.

cmScaleX Number

camera scale x to use if scaling camera. for example window.innerWidth / camera.width

cmScaleY Number

camera scale y to use if scaling camera.

seekTouch()

Trys to determine if a touch device is being used. If the browser is an Edge browser an actual touch has to happen before this would return true. On Chrome and Firefox this returns true on touch devices and in dev tools.

stringSplitter(str, ntimes)

tabageos.stringSplitter

Splits a string ntimes amount of times. The result gets output to the console.

Parameters:
Name Type Description
str string

The String to split

ntimes Number

The amount of times to split the string