Jump to content

Search the Community

Showing results for tags 'string'.

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • HTML5 Game Coding
    • News
    • Game Showcase
    • Facebook Instant Games
    • Web Gaming Standards
    • Coding and Game Design
    • Paid Promotion (Buy Banner)
  • Frameworks
    • Pixi.js
    • Phaser 3
    • Phaser 2
    • Babylon.js
    • 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

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Twitter


Skype


Location


Interests

Found 2 results

  1. Hi all, I have a collection of five bee spritesheets and I have assigned them unique strings such as, 'bee1', 'bee2' etc. I randomly generate a character/bee at the start of each game by: // Randomly generate an integer and identify unique string var randomBee = 'bee'+ this.game.rnd.integerInRange(1,5); // Add sprite this.bee = this.game.add.sprite(100, 245, randomBee); HOWEVER, I wanted to display the characters name (top right): var beeName = getName(randomBeeKey); AND function getName(beeKey) { if(beeKey === "bee1") return "Boobee"; if(beeKey === "bee2") return "Digbee"; if(beeKey === "bee3") return "Feebee"; if(beeKey === "bee4") return "Abbee"; if(beeKey === "bee5") return "Newbee"; } I can't seem to get it working, any help would be appreciated! Here's my code if I'm not making sense: http://pastebin.com/dGpW5ezw
  2. Hello, I'm using BSP to build an array for level generation. For now, the 2d array contains either a 0 or 1, for empty space or where a tile should be. I'm then trying to use the array as a string to pass into the tilemap function. However, none of the methods I've tried for generating the tilemap are working. The closest I've been able to get is throwing an error in phaser.js's getIndex function, saying that the "location" property is undefined. That seems like this issue, but that's been reported as fixed. I'm using version 2.4.4 of Phaser. I saw another thread that said 0 shouldn't be used, because when Phaser loops through the data, it only looks for things greater than 0. I changed it to use 1 for empty space, and 12 for a tile (just to pick something from my tilesheet), but that made no difference. Someone please tell me what I'm doing wrong! Here is the tilemap I slapped together for testing: Here's the code I'm using (stripping out all of the level generation stuff): var TILE_SIZE = 32;var WIDTH_RATIO = 0.45;var HEIGHT_RATIO = 0.45;var ITERATIONS = 4;var mainRoom = undefined;var levelArr = [];var map;var BSP2 = function (){ this.levelWidth = 0; this.levelHeight = 0; this.tilesPerRow = 0; this.tilesPerColumn = 0; this.roomTree = undefined; this.rooms = [];};BSP2.prototype = { init: function(levelWidth, levelHeight) { this.levelWidth = levelWidth; this.levelHeight = levelHeight; this.tilesPerRow = levelWidth/TILE_SIZE; this.tilesPerColumn = levelHeight/TILE_SIZE; mainRoom = new RoomContainer(0, 0, this.levelWidth, this.levelHeight); levelArr = new Array(this.tilesPerColumn); for(var i = 0; i < this.tilesPerColumn; i++) { levelArr[i] = new Array(this.tilesPerColumn); } for(var c = 0; c < this.tilesPerColumn; c++) { for(var r = 0; r < this.tilesPerRow; r++) { levelArr[c][r] = 1; } } }, preload: function() { //console.log("bsp2.js - preload()"); game.load.image('img_leveltiles_test', 'leveltiles_test.png'); }, create: function() { //console.log("bsp2.js - create()"); game.add.sprite(0, 0, 'bg_background'); ... this.drawTiles(); }, drawTiles: function() { game.load.tilemap('tilemap', null, [levelArr.toString()], Phaser.Tilemap.TILED_JSON); map = game.add.tilemap('tilemap'); map.addTilesetImage('tileimage', 'img_leveltiles_test', TILE_SIZE, TILE_SIZE); map.create('firstlevel', this.levelWidth/TILE_SIZE, this.levelHeight/TILE_SIZE, TILE_SIZE, TILE_SIZE); }};And this is what a typical array-to-string setup looks like:
×
×
  • Create New...