Welcome to PizzaJS Docs
Importing PizzaJS
1. Download latest version from github.
Make sure to have PizzaJS files as the template/project
as an alternative use the template for your project provided in github at template/project
Example
2. Use any importing method
After choosing the import method, start creating your game or project. :D
Global object
Attributes | Description |
---|---|
version |
Holds the current version in a string |
build |
Current build |
debug |
Just as a feature. No class has any special atribute when its true. |
all |
An array that holds all actors,sliders,buttons and rects. |
actors |
An array with all the actors. |
buttons |
An array with all the buttons. |
sliders |
An array with all the sliders. |
rects |
An array with all the rects. |
sounds |
An array that holds all sounds. |
fps |
Current fps. |
hasLoaded |
Indicator that tells if all assets where loaded. |
toLoad |
A number that show how many things it has to load. |
Loaded |
A number that show how many things loaded. |
loadingTime |
Default max loading time. |
hasSetup |
A boolean that indicates if it has been already setted up. |
setupWidth |
Width of the canvas when it was setted up |
setupHeight |
Height of the canvas when it was setted up |
shakingScreen |
Indicates if the screen is shaking |
allListenersHadSetup |
Indicates if all listeners had been setted up |
mouseListenersHadSetup |
Indicates if the mouse listener has been setted up |
keyboardListenersHadSetup |
Indicates if the keyboard listener has been setted up |
resizeListenersHadSetup |
Indicates if the resize listener has been setted up |
_ImagesLoadedURL_ |
All images loaded using loadImage(); |
_SoundsLoadedURL_ |
All sounds loaded using loadSound(); |
errors |
A set that has all current errors in PizzaJS |
Example
Output: 1920
Time object
Attributes | Description |
---|---|
delta |
Represents the time elapsed between the current frame and the previous frame. This attribute, commonly referred to as deltaTime. |
time |
Each frame time.delta is added. Could be used for animations |
scale |
Represents a scaling factor for some operation |
frameCount |
How many frames it rendered since the start. |
Example
Output: 60
Events
pjsUpdate
Trigger:
This event is triggered after the start() function is called. And calls itself each framePurpose:
It indicates update or initialization process has taken place.
pjsAfterUpdate
Trigger:
This event occurs after the pjsUpdate event.Purpose:
Made for drawing on top of what is drawn onpjsUpdate
generally used for Addons.
pjsAfterClear
Trigger:
This event is triggered after calling the clear() function.Purpose:
Made for drawing beforepjsUpdate
generally used for Addons.
How to use color code format
On classes instead of putting an image, color can by used by simply adding color:
before the color wether is on hex, rgb, rgba, etc.
Example
Using radius and stroke property
Example
Licenses
PizzaJS license
buttons.js
This page uses a modified version of github buttons.js.
Modified version is located in pizzajs/mkdocs/social-buttons.js
.
Original version at https://github.com/buttons/github-buttons/blob/main/dist/buttons.js.