denisb

Members
  • Content Count

    9
  • Joined

  • Last visited

About denisb

  • Rank
    Newbie

Recent Profile Visitors

604 profile views
  1. Thanks for the detailed info Tom! I'm using 2.4.4 so that would be the problem.
  2. Lets say I have this code: var mySprite=this.add.sprite('mySprite'); mySprite.alpha=0; var mySpriteTween=this.add.tween(mySprite); mySpriteTween.to({alpha:1},1000,'Linear',false,0,0,true); mySpriteTween.start(); mySpriteTween.start(); When I call start() the second time the tween does not run even though I have yoyo set to true and thus the alpha of mySprite has been tweened back to zero. Does the Tween Manager clear the TweenData object owned by mySpriteTween after it has completed?
  3. Lets say I create 2 states, stateA and stateB. I start stateA which creates a sprite object and adds it to the World. Then I start stateB, assign the sprite object that was created in StateA and added to World, to a variable in stateB. Will I not be able to access the sprite because it was destroyed when I changed states? Do I need to create another sprite and add it to the World?
  4. Ah, you're brilliant Mr. Batzi! Thanks a million.
  5. Thanks for the help. I thought the tween needed to run in the update function. Thanks for clearing that up for me. Also, do you have any clue why the alpha can change from 1 to 0 but not 0 to 1. The setTimeout works but I'm just curious. If I can figure it out I'll post the answer.
  6. In the code below I create a graphics object with an alpha of 0. I then create a tween object using the graphics object as the target. In the update function I change the alpha value of the graphics object from 0 to 1 using the tween. This does not work. However, when I create the graphics object using an alpha value of 1 and change the value from 1 to 0, using the tween, it does work. Can someone explain this to me? var MyGame={}; MyGame.Test=function(){ this.rectangle; this.tweenRectangle; this.switch=true; }; MyGame.Test.prototype={ create:function(){ this.rectangle=this.add.graphics(); this.rectangle.lineStyle(0); this.rectangle.beginFill(0x992d2d,0); this.rectangle.drawRect(0,0,600,600); this.rectangle.endFill(); this.tweenRectangle=this.add.tween(this.rectangle); }, update:function(){ if(this.switch){ this.tweenRectangle.to({alpha:1},5000,"Linear",true); this.switch=false; } } };
  7. It works when I change each axis in update: from this.spacecraft.body.y-=4 to this.spacecraft.body.velocity.y=-200 and so on. Can anyone explain why this works while the other way does not?
  8. I can't figure out why my spacecraft overlaps with the asteroid and does not collide. I used Phaser.Utils.Debug and found that the display objects to not touch each other. Are the bodies in different containers? Thanks for your help. var MyGame={}; MyGame.Level1=function(){ this.spacecraft; this.asteroid; this.cursors; }; MyGame.Level1.prototype={ preload:function(){ this.load.image('spacecraft', 'assets/spacecraft.png'); this.load.image('asteroid', 'assets/asteroid.png'); }, create:function(){ this.game.physics.startSystem(Phaser.Physics.ARCADE); this.asteroid=this.add.sprite(500,100,'asteroid'); this.physics.arcade.enable(this.asteroid,Phaser); this.asteroid.body.immovable=true; this.spacecraft=this.add.sprite(0,100,'spacecraft'); this.game.physics.arcade.enable(this.spacecraft); }, update:function(){ this.physics.arcade.collide(this.spacecraft,this.asteroid,this.collisionHandler,this.processHandler,this); if(this.game.input.keyboard.isDown(Phaser.Keyboard.UP)){ this.spacecraft.body.y-=4; } else if(this.game.input.keyboard.isDown(Phaser.Keyboard.DOWN)){ this.spacecraft.body.y+=4; } if(this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT)){ this.spacecraft.body.x-=4; } else if(this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)){ this.spacecraft.body.x+=4; } }, processHandler:function(spacecraft,asteroid){ return true; }, collisionHandler:function(spacecraft,asteroid){ spacecraft.kill(); } };
  9. The book, Interphaser 1 lists 19 predefined properties of the State object on page 17. One of these properties is state which is a reference to the Phaser.StateManager. However, State.js does have a state property that is a reference to the Phaser.StateManager. Is this an error in Interphaser 1 or am I missing something?