Impact

This forum is read only and just serves as an archive. If you have any questions, please post them on github.com/phoboslab/impact

1 decade ago by JackImpact

Hi All,

I am stucked with this.currentAnim.flip.x. very weird!

this.currentAnim.flip.x=this.flip; is working fine in init() but not in update();

when added in update(), it throws an error saying TypeError: 'undefined' is not an object (evaluating 'this.currentAnim.filp.x=this.flip')

no clue why this is happening...

what I am trying to do with this entity is to get the entity loop in a range, change vel.x and flip.x when hitting the boundary of the range.






ig.module(
	'game.entities.enemyHBDive'
)
.requires(
    'impact.entity',
	'game.entities.enemy'
)

.defines(function(){
	EntityEnemyHBDive=EntityEnemy.extend({
		
		   animSheet: new ig.AnimationSheet( 'media/hamburglerDive.png', 135, 59 ),
		   
		   name:'HBDive',
		   size: {x:135, y:59},
		   offset: {x: 0, y: 0},
		   vel:{x:20,y:0},
		   
		   initialX:0,
		   initialY:0,
		   
		   health:9,
		   fTimer: new ig.Timer(4),
		   friction:{x:0.1,y:0.1},
		  //checkAgainst: ig.Entity.TYPE.B,
		   type:ig.Entity.TYPE.B,
		   collides: ig.Entity.COLLIDES.PASSIVE,
		   bounciness: 1,
		   frozen:false,
		   zIndex:-201,
		   scale:{x:0.6,y:0.6},
		   FloatSpeed:0,
		   flip:false,
		   
		   hDistance:100,
		   
		   init: function( x, y, settings ) {
				this.parent( x, y, settings );
				this.addAnim( 'idle', 1, [0] );
				this.addAnim( 'frozen', 1, [0] );
                //this.addAnim( 'float', 0.07, [1,2,3,4] );
				this.size.x=this.size.x*this.scale.x;
				this.size.y=this.size.y*this.scale.y;
				
				this.initialX=x;
				this.initialY=y;
				
				this.currentAnim.flip.x=this.flip;
				
				
				},
			
   		 // handleMovementTrace:function(res){
				//this.parent(res);
			
					//if(res.collision.x||res.collision.y){
//						this.flip=!this.flip;
//					    this.currentAnim.flip.x=this.flip;
//						}
		
				//},
				
			update:function(){
			
				this.pos.y+=Math.cos(this.FloatSpeed)*0.1;
			  	this.FloatSpeed+=Math.PI/180;
				
			    this.parent();
				
				if(this.pos.x>this.initialX+this.hDistance||this.pos.x<this.initialX-this.hDistance){
					this.vel.x=-this.vel.x;
					
					if(this.flip==true){
						this.flip=false;
					}else if(this.flip==false){
						this.flip=true;
						}
					
					this.currentAnim.filp.x=this.flip;
					console.log(this.flip);
					//
					}
				},
				
			
			
		
			draw:function(){
				
				
				
				this.parent();
			

				}
				
		
	
		});
	});

1 decade ago by dominic

It&039;s #.flip, not .filp :)

1 decade ago by JackImpact

that is embarrassing! You really have good eyes Dominic. Many thanks! It bothered me for days. It is working very well now
Page 1 of 1
« first « previous next › last »