Skip to content

Instantly share code, notes, and snippets.

Notes on using PIXI Renderer

Assets

  • PIXI loads various image & json data only. Image data for both sprites and fonts. JSON data utilized with Texture packer for texture atlas.
  • Due to the way PIXI Sprite work, I think it would be wise to hook into the PIXI Textures similar to how phaser does it: https://github.com/photonstorm/phaser/blob/master/src/loader/Cache.js#L303. It will take some experimenting to see how to hook it properly into the loader callback. This also goes for things like tileset images, TPS, etc.

The container

We can potentially keep the container as we have it, but I'm not sure if that would really be ideal, giving the fact PIXI uses its own. This would handle various optimizations for us. But to keep entity pooling the same, we'll need to write a wrapper for it. addChild and removeChild luckily exist. For an index t

/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
ig.module(
'plugins.touch-button'
)
.requires(
'impact.system',
'impact.input',
'impact.image'
)
.defines(function(){
@agmcleod
agmcleod / gist:6125657
Created July 31, 2013 20:05
array testing
require 'benchmark'
arr = [
]
Benchmark.bm do |x|
x.report 'class check' do
100.times.each do |i|
100_000.times.each do |j|
@agmcleod
agmcleod / trickshots.md
Created June 26, 2013 14:33
Ruby trickshots

Ruby trickshots

irb: rand(10..30) # create a random between a range

$ gem install awesome_print
irb: require 'ap'; ap [0,1,2]

x = 'string'; x['st'] # => 'st'

include A, B, C # include multiple modules in one line

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<title></title>
<meta name="viewport" content="width=device-width, minimum-scale=1.0" />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
</head>
<body>
</body>
@agmcleod
agmcleod / url_parser.rb
Created March 13, 2013 23:01
To run, you need ruby 1.9.2+. Pass the csv containing urls as an argument.
require 'csv'
require 'net/http'
responses = []
CSV.foreach(ARGV[0]) do |row|
responses << "#{row},#{Net::HTTP.get_response(URI.parse(row[0]))}"
puts row
end
IO.write("url_responses.csv", responses.join("\n"))
var sys = require("sys"),
my_http = require("http"),
path = require("path"),
url = require("url"),
filesys = require("fs");
my_http.createServer(function(request,response){
var my_path = url.parse(request.url).pathname;
var full_path = path.join(process.cwd(),my_path);
path.exists(full_path,function(exists){
if(!exists){
(function() {
Ajax.Responders.register({
onCreate: function(request) {
var token = $$('meta[name=csrf-token]')[0];
if (token) {
if (!request.options.requestHeaders) request.options.requestHeaders = {};
request.options.requestHeaders['X-CSRF-Token'] = token.readAttribute('content');
}
}
});
@agmcleod
agmcleod / gist:4725819
Created February 6, 2013 21:03
This would be funny to inject in a browser request.
<style type="text/css">
body {
transform:rotate(180deg);
-webkit-transform: rotate(180deg);
-moz-transform:rotate(180deg);
-ms-transform:rotate(180deg);
-o-transform:rotate(180deg);
}
</style>