Jump to content

Search the Community

Showing results for tags 'IIFE'.

  • 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 1 result

  1. Hi, there! Newcomer here! Last night I began exploring Phaser. First I wrote everything in one js file. Then I decided to use IIFEs to organize my code. But I stumbled upon a problem I don't know how to fix. I have player.js and main.js. Player.js: var hero = (function(){ var hero = { init: function(){ hero = game.add.sprite(game.world.width / 2, 0, 'idle'); << ReferenceError this.scale.setTo(0.6, 0.6); game.physics.arcade.enable(this); this.body.collideWorldBounds = true; } }; return hero;}());And main.js has: var game = new Phaser.Game(800, 600, Phaser.AUTO, '', { preload: preload, create: create, update: update });........The error I get(as some of you might already guess) is "Uncaught ReferenceError: game is not defined". The only option I can think of so far is to instantiate another game in the player but that sounds completely wrong. I'm not too good with IIFEs and I find a perfect opportunity to understand them better while writing this game. Thanks in advance!
×
×
  • Create New...