Jump to content

Search the Community

Showing results for tags 'utility'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Panda 2
    • melonJS
    • Haxe JS
    • Kiwi.js
  • General
    • General Talk
    • GameMonetize
  • Business
    • Collaborations (un-paid)
    • Jobs (Hiring and Freelance)
    • Services Offered
    • Marketplace (Sell Apps, Websites, Games)

Find results in...

Find results that contain...

Date Created

  • Start


Last Updated

  • Start


Filter by number of...


  • Start



Website URL





Found 3 results

  1. This is hastily thrown together code that I created as a solution for an idea that I have. I have texture gen data in objects and I wanted to merge various layers together. Reason being is if I create a number of various objects I wanted them to be placed on buttons later on. I plan on making a some code to replace various parts of the textures so that I can on the fly generate generated textures. This is handy for button and things of that nature which is why I created it. I decided to throw it out there in case anyone needed something like this or wanted to improve on the code. Also here is a working example of it on jsfiddle. Screenshot var game = new Phaser.Game(800, 600, Phaser.CANVAS, '', { create: create }); // taken from my code and striped out useless parts var gameScale = 2 var sprite = (function() { 'use strict'; var sprite = { creature: {}, misc: {}, object: {}, structure: {}, tile: {}, vehicle: {}, }; sprite.misc.buttonBackground = { size: [16, 16], data: [ '0000000000000000', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0999999999999990', '0000000000000000' ], }; sprite.object.table = { size: [6, 3], thumbOffset: [5, 8], data: [ '666666', '.6..6.', '.6..6.' ], thumbData: [ '666666', '.6..6.', '.6..6.' ], }; sprite.mergeData = function mergeData(bgData, fgData, xOffset, yOffset) { var bgDimensions = sprite.getDimensions(bgData); var fgDimensions = sprite.getDimensions(fgData); var size = sprite.getMaxDimensions(bgDimensions, fgDimensions); var newData = []; _.times(size[1], function(y) { var row = ''; _.times(size[0], function(x) { var s = '.'; if (yOffset || xOffset) { if (y >= yOffset || x >= xOffset) { if (fgData[y - yOffset] && fgData[y - yOffset][x - xOffset]) { s = fgData[y - yOffset][x - xOffset]; } } } else { if (fgData[y] && fgData[y][x]) { s = fgData[y][x]; } } if (s == '.' && bgData[y] && bgData[y][x]) { s = bgData[y][x]; } row += s; }); newData.push(row); }); return newData; }; sprite.makeTexture = function makeTexture(name, data) { console.info('Loading sprite `%s`.', name); return game.create.texture( name, data, gameScale, gameScale ); }; sprite.getDimensions = function getDimensions(spriteData) { if (_.isArray(spriteData)) { var y = spriteData.length; var x = 0; var count = 0; _.each(spriteData, function (row) { if (row.length > x) x = row.length; }); count = x * y; return [x, y, count]; } return false; }; sprite.getMaxDimensions = function getMaxDimensions(a, b) { if (!_.isArray(a) || !_.isArray(b)) return false; var x = Math.max(a[0], b[0]); var y = Math.max(a[1], b[1]); return [x, y]; }; return sprite; })(); function create() { game.stage.backgroundColor = '#2d2d2d'; // manually placed variables from itterated code; var groupKey = 'object'; var structKey = 'table'; var col = 0; var row = 0; var name = groupKey + '_' + structKey; var baseLeft = 100 + ((col * 16) * gameScale) + 2; var baseTop = 100 + ((row * 16) * gameScale) + 2; var bgData = sprite.misc.buttonBackground.data; var fg =sprite[groupKey][structKey]; var fgData = fg.thumbData; var newData; if (_.isUndefined(fg.thumbOffset)) { newData = sprite.mergeData(bgData, fgData); } else { newData = sprite.mergeData(bgData, fgData, fg.thumbOffset[0], fg.thumbOffset[1]); } var btnName = 'btn_' + name; var newTexture = sprite.makeTexture(btnName, newData); var objButton = game.add.sprite( baseLeft, baseTop, btnName); objButton.name = name; objButton.inputEnabled = true; objButton.input.useHandCursor = true; }
  2. Hi all, I'm new to these forums, but really want to share what I've made with everyone. Not for my own sake but to help all those other game developers out there that have trouble deciding what resolutions/aspect ratios to target. I built this utility to help me visualize how common aspect ratios display on any screen size when stretched to fill the screen as much as possible. All you have to do is deploy the URL on any device to see how a game of size 4:3, 3:2, or 16:9 will display. You can even just use your browser and stretch the window to the target size so you can do all your planning from the PC. however I recommend loading it up on the device as there are software bars and URL bars to consider! In any case, please take a look - I feel we all have something to gain from having a visual aid when planning our target resolutions. Just click the banner below! You can also see an augmented version of this scaling logic in action in our upcoming title, Dragonfly Zero. Click the banner below and stretch the window to whatever size you want. The game will scale and implement extra filler as is appropriate for the aspect ratio - regardless of how tall or wide you make it! --------------------------------- UPDATE (5/7/14): Made changes requested by turnA, designated v2.0 This version includes both portrait and landscape in the same utility for ease of testing New screenshots as well Notes: There may be minor discrepancies of 1-2px either visually, or represented in the information panel. Each box includes it’s border as a representation of it’s aspect ratio. This means the game screen box will overlap the borders when matching aspect ratios. The utility will automatically switch between portrait and landscape orientations (if height exceeds width in landscape, or width exceeds height in portrait). The orientation label also works as a button. Portrait mode is somewhat restricted on landscape displays (text size reduction), works best on flipped monitors and portrait displays. SCREENSHOTS Landscape - iPhone 5S, safari (iOS) Portrait - iPhone 5S, Safari (iOS) Landscape - PC, Google Chrome (windows)
  3. What I aim to do with this blog post is set people on the right path from the get go with how image size in RAM works. I also want to provide others with the system I used to audit my image RAM and process I used to cut out inefficiencies. This should help you to get a good visual overview of which of your images are wasting the most RAM and where you can cut the fat. You can plug in the image asset list from your exported project and the sheet will give you some nice color coded information that isn't too hard on the eyes. Just click the banner above or, you can click this link too: http://pangolingames.com/how-to-audit-image-ram/ There is a RAM vs Storage overview before it gets to the utility itself, that should hopefully help explain how image download size and image size in RAM are not the same thing. In any case, I hope you find it an enjoyable and enlightening read! If you find anything that's incorrect, let me know!
  • Create New...