Jump to content

Search the Community

Showing results for tags 'global variables'.

  • 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. So i'm relatively new to JS and Phaser. I'm using yeoman to scaffold phaser and it is all working fine...except for global variables. I'm too new to coding in general to bend everything to my will. the issue i'm having is trying to get a prefab to talk to the 'play' state. I have a function inside my prefab: var destroyBacon = function() { this.destroy(); this.game.score += 1;}; the 'this.destroy();' works perfectly. but I want for every time I use that function (which is every time I click a sprite from that prefab) to add a point to the 'score'. I get this every time: Uncaught TypeError: Cannot read property 'score' of null I'm not sure if I should even be using the 'this.game.' or where I should put the actual score variable. Ideally, I'd like each of my prefabs (of sprites) to add to the score. any advice would definitely help.
×
×
  • Create New...