Jump to content
This forum will be closing down. Please move to the respective dedicated project forums.

[Solved]How is it possible to call this function?


khleug35
 Share

Recommended Posts

here is my code

 <script>
var game = new Phaser.Game(372, 635, Phaser.AUTO, 'game');
game.state.add('menu',menu); 
game.state.add('Level1',Level1);
game.state.start('menu');    
</script>  

//Level1.js

var Level1 = {
init: function() {
this.play = true;  <---------/*I want to call it in  Enemy: function(){this.init = function()*/-->
},

 preload: function() {
    this.load.im..........
}, 
create: function() {
    this.enemy = new this.Enemy();
    this.enemy.init();
},
  update: function() {
........
},
 Enemy: function(){

    this.init = function (){
    console.log(this.play);  <-----------/*I want to call this.play = true, but it show undefined*/
    if(this.play == true){  <-----------/*I want to call this.play = true, but it show undefined*/
         dosomething.....
    }else{
         dosomething.....
}

     }

I want to call  "this.play = true; "     in  Enemy: function(){    this.init = function ()

but it is not successful......the chrome console is display show "undefined"

How is it possible to call this function??? thx very much

a.png

b.png

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...