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
var count = 0; | |
for(var i=0; i<ig.game.entities.length; i++) { | |
if(ig.game.player.touches(ig.game.entities[i])) { | |
count++; | |
} | |
} | |
console.log(count); |
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
getbodyCount = function() { | |
var count = 0; | |
for( var body = ig.world.GetBodyList(); body; body = body.m_next ) { | |
count++; | |
} | |
console.log(count); | |
} |
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
startTimer = function() { | |
var start = new Date().getTime(); | |
return start; | |
}; | |
stopTimer = function(start) { | |
var end = new Date().getTime(); | |
var time = end - start; | |
return time; | |
}; |
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
// This is how to manually set the frames per second in ImpactJS. | |
setTimeout(function() { | |
var fps = 60; | |
ig.system.stopRunLoop(); | |
window.setInterval( ig.system.run.bind(ig.system), 1000/fps ); | |
}, 0); |
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
ig.system.context.save(); | |
ig.system.context.fillStyle = '#A6E22E'; | |
var radius = 3 * ig.system.scale; | |
for (var body = ig.world.GetBodyList(); body; body = body.GetNext()) { | |
for (var fixture = body.GetFixtureList(); fixture; fixture = fixture.GetNext()) { | |
var shape = fixture.GetShape(); | |
if (shape.GetType() == Box2D.Collision.Shapes.b2Shape.e_polygonShape) { | |
var poly = shape; | |
poly.GetVertices().forEach(function(vertex) { | |
var pos = body.GetWorldPoint(vertex.Copy()); |
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
jQuery('.chat-session').each(function() { | |
var session = jQuery($(this)); | |
var other_name = session.find('.name').text(); | |
session.find('.chat-messages').each(function() { | |
var list = jQuery($(this)); | |
list.find('li').each(function() { | |
var list_item = jQuery($(this)); |
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
/* | |
Usage: | |
ig.module('game.entities.example') | |
.requires('impact.entity', 'plugins.entity-blinking') | |
.defines(function() { | |
EntityExample = ig.Entity.extend({ | |
size: { x: 32, y: 32 }, |
NewerOlder