Skip to content

Instantly share code, notes, and snippets.

@jdfight
jdfight / FindObjectsTiled.js
Last active January 6, 2018 17:19
Phaser - Creating objects from Tiled Map Object layers
//From http://www.gamedevacademy.org/html5-phaser-tutorial-top-down-games-with-tiled/
//find objects in a Tiled layer that containt a property called "type" equal to a certain value
findObjectsByType: function(type, map, layer) {
var result = new Array();
map.objects[layer].forEach(function(element) {
console.log(element);
if (element.properties.type === type) {
//Phaser uses top left, Tiled bottom left so we have to adjust the y position
//also keep in mind that the cup images are a bit smaller than the tile which is 16x16
ig.module(
'game.plugins.gamepad'
)
.requires(
'impact.input',
'impact.game'
)
.defines(function(){
// Assign some values to the Gamepad buttons. We use an offset of 256
@geoffb
geoffb / edit-entities.js.diff
Created January 10, 2011 17:32
ImpactJS Weltmiester: Don't consider entity offset when snapping to grid.
diff --git a/htdocs/lib/weltmeister/edit-entities.js b/htdocs/lib/weltmeister/edit-entities.js
index f9d9250..6272f3e 100644
--- a/htdocs/lib/weltmeister/edit-entities.js
+++ b/htdocs/lib/weltmeister/edit-entities.js
@@ -141,7 +141,7 @@ wm.EditEntities = ig.Class.extend({
for( var i = 0; i < this.entities.length; i++ ) {
var ent = this.entities[i];
if( ent.touches(this.selector) ) {
- this.selector.offset = {x: (x - ent.pos.x + ent.offset.x), y: (y - ent.pos.y + ent.offset.y)};
+ this.selector.offset = {x: (x - ent.pos.x), y: (y - ent.pos.y)};