Skip to content

Commit ddfc6b0

Browse files
authored
v1.2
1 parent 2f2d39b commit ddfc6b0

File tree

1 file changed

+34
-5
lines changed

1 file changed

+34
-5
lines changed

lib/poliphaser.js

Lines changed: 34 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
console.log('%c PoliPhaser - Version 1.01 ', 'background: #728FA5; color: white; font-size:20px;');
1+
console.log('%c PoliPhaser - Version 1.2 ', 'background: #728FA5; color: white; font-size:20px;');
22

33
/************* HELPER FUNCTIONS *************/
44

@@ -372,6 +372,7 @@ PP.debug = {
372372
* @param {number} config.background_color Default background color used when no background is drawn, in RGB HEX format (for example 0x000000).
373373
* @param {boolean} config.debug_mode It defines whether PoliPhaser should run in debug mode showing various debug information.
374374
* @param {number} config.gravity_value The value of gravity in pixels per second squared.
375+
* @param {boolean} config.pixel_art It defines whether pixel art should be enabled or disabled.
375376
* @return A game object. The user should not directly manipulate it, but pass it to other functions.
376377
*/
377378
PP.game.create = function (config) {
@@ -405,7 +406,7 @@ PP.game.create = function (config) {
405406
height: config.canvas_height,
406407
backgroundColor: config.background_color,
407408
scene: PP.scenes.list,
408-
pixelArt: true,
409+
pixelArt: config.pixel_art ?? true,
409410
parent: config.canvas_id,
410411
physics: {
411412
default: 'arcade',
@@ -656,7 +657,6 @@ PP.assets.image.load = function(scene, image_path) {
656657
let url_hash = __PP_internal_cyrb53(image_path); // This is used as ID
657658

658659
if(PP.assets.list_images_id.includes(url_hash)) {
659-
console.warn('WARNING: you are trying to load multiple times the same image/spritesheet ('+image_path+'). Aborting this load request.');
660660
return {id: url_hash, type: "image"};
661661
}
662662

@@ -725,7 +725,6 @@ PP.assets.sprite.load_spritesheet = function(scene, image_path, frame_width, fra
725725
let url_hash = __PP_internal_cyrb53(image_path); // This is used as ID
726726

727727
if(PP.assets.list_images_id.includes(url_hash)) {
728-
console.warn('WARNING: you are trying to load multiple times the same image/spritesheet ('+image_path+'). Aborting this load request.');
729728
return {id: url_hash, type: "sprite"};
730729
}
731730

@@ -929,7 +928,6 @@ PP.assets.destroy = function(obj) {
929928
PP.debug.assert(typeof obj.ph_obj === "object", "Parameter error: obj is not a valid PP object instance.");
930929

931930
obj.ph_obj.destroy();
932-
933931
}
934932

935933
/**
@@ -1352,10 +1350,24 @@ PP.camera.set_follow_offset = function(scene, offset_x, offset_y) {
13521350
}
13531351

13541352

1353+
/**
1354+
* Return the scroll on the x axis of the camera.
1355+
* They represent the distance between the top-left of the camera's world view and its viewport.
1356+
* @function get_scroll_x
1357+
* @memberof PP.camera
1358+
* @param {object} s The scene object.
1359+
*/
13551360
PP.camera.get_scroll_x = function(s) {
13561361
return s.cameras.main.scrollX;
13571362
}
13581363

1364+
/**
1365+
* Return the scroll on the y axis of the camera.
1366+
* They represent the distance between the top-left of the camera's world view and its viewport.
1367+
* @function get_scroll_y
1368+
* @memberof PP.camera
1369+
* @param {object} s The scene object.
1370+
*/
13591371
PP.camera.get_scroll_y = function(s) {
13601372
return s.cameras.main.scrollY;
13611373
}
@@ -1596,6 +1608,12 @@ PP.physics.add_overlap_f = function(s, obj1, obj2, func) {
15961608
return {ph_collider: ph_obj};
15971609
}
15981610

1611+
/**
1612+
*
1613+
* Remove a previously created collider (or overlap)
1614+
* @param {object} s The scene
1615+
* @param {float} obj The collider (or overlap) to be removed as returned from functions like add_collider.
1616+
*/
15991617
PP.physics.remove_collider_or_overlap = function(s, obj) {
16001618
PP.debug.assert(typeof s === "object", "Parameter error: s should be an object.");
16011619
PP.debug.assert(typeof obj === "object", "Parameter error: obj should be an object.");
@@ -1604,6 +1622,17 @@ PP.physics.remove_collider_or_overlap = function(s, obj) {
16041622
s.physics.world.removeCollider(obj.ph_collider);
16051623
}
16061624

1625+
/**
1626+
*
1627+
* Change the value of the gravity
1628+
* @param {object} s The scene
1629+
* @param {float} new_gravity The new value in px/s2 of the gravity in the y axis.
1630+
*/
1631+
PP.physics.change_gravity = function(s, new_gravity) {
1632+
s.physics.world.gravity.set(0,new_gravity);
1633+
PP.game.config.gravity_value = new_gravity;
1634+
}
1635+
16071636
/**
16081637
*
16091638
* Set the bounce value over the horizontal axis (0: no bounce, 1: full bounce).

0 commit comments

Comments
 (0)