-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add transparent background hack
- Loading branch information
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
/** | ||
🔳 | ||
@file transparent background | ||
@summary makes the game have a transparent background | ||
@license MIT | ||
@version auto | ||
@requires Bitsy Version: 7.2 | ||
@author Cephalopodunk & Sean S. LeBlanc | ||
@description | ||
Makes the game background transparent, showing whatever would be visible behind it in the html document. | ||
Note: also includes transparent sprites | ||
HOW TO USE: | ||
1. Copy-paste this script into a script tag after the bitsy source | ||
2. Edit hackOptions below as needed | ||
*/ | ||
import { inject } from './helpers/kitsy-script-toolkit'; | ||
import { hackOptions as transparentSprites } from './transparent sprites'; | ||
|
||
export var hackOptions = { | ||
// transparent sprites option | ||
isTransparent: function (drawing) { | ||
// return drawing.name == 'tea'; // specific transparent drawing | ||
// return ['tea', 'flower', 'hat'].indexOf(drawing.name) !== -1; // specific transparent drawing list | ||
// return drawing.name && drawing.name.indexOf('TRANSPARENT') !== -1; // transparent drawing flag in name | ||
return true; // all drawings are transparent | ||
}, | ||
}; | ||
|
||
transparentSprites.isTransparent = function (drawing) { | ||
return hackOptions.isTransparent(drawing); | ||
}; | ||
|
||
inject(/ctx.fillRect(\(0,0,canvas.width,canvas.height\);)/g, 'ctx.clearRect$1'); | ||
inject(/context.fillRect(\(0,0,canvas.width,canvas.height\);)/g, 'context.clearRect$1'); |