Hashasm

Members
  • Content count

    88
  • Joined

  • Last visited

  1. Hi guys , I am almost done with my game now the only thing to take care is browser cache .. the problem is when I am changing my json through playing game and if i am trying to fetch that json tmx file its still giving me the wrong input until i clear my cache and if i clear my cache and cookie my session also removing .. is their any way to clear my cache without affecting my session through melon or simple javascript.. please let me know. i am using chrome and mozilla! thanks HAPPY GAMING
  2. hi all, @Parasyte i found the solution , but i dint change my code , what i did is passing the co-ordinates by converting row and col values .. but before i was passing the coordinates by using event.gameWorld .. but i am curious to understand in depth about setting velocity and acceleration . if you have any resource for the same please share with me thank you
  3. hi @01271 can you tell me wether i am updating velocity in correct place or not game.PlayerEntity = me.Entity.extend({ // _patrol_isReverse: false, init: function(data,rand_color) { this.patrol_path = []; this.patrol_isReverse = false; this.patrol_isInfinite = true; var settings={} //console.log(this.gameWorldX+" "+this.clientX); /* var roadlayer =me.game.world.getChildByName("waterLayer")[0]; var tile= roadlayer.getTile(this.gameWorldX, this.gameWorldY); console.log(tile.row+""+tile.col); */ var vehicle_name; // console.log(data.frequency) if(data.frequency=="RealTime"){ // vehicle_name="chopper"; vehicle_name="scooter_"+rand_color; // vehicle_name="truck_"+rand_color; } else if(data.frequency=="Daily"){ // vehicle_name="van_"+rand_color; // vehicle_name="mini_truck_"+rand_color; // vehicle_name="HORSE_CARRIAGE_"+rand_color; vehicle_name="chopper_"+rand_color; // vehicle_name="chopper_float-01"; } else if (data.frequency=="Monthly"){ vehicle_name="car_"+rand_color; } else if(data.frequency=="BiWeekly"){ vehicle_name="HORSE_CARRIAGE"; } else{ vehicle_name="scooter_"+rand_color; } game.texture = new me.video.renderer.Texture( { framewidth : 48, frameheight : 48, anchorPoint : new me.Vector2d(0.5, 0.5) }, me.loader.getImage(vehicle_name) //make this dynamic ); var obj = game.texture.getAtlas() //make this dynamic settings.width = 0; settings.height =0; var x=data.path[0].x; var y= data.path[0].y; console.log("x"+x+" ==y=="+y); this._super(me.Entity, "init", [/*7324, 3702*/x,y, settings]); this.body.setVelocity(1.8,1.8); this.renderable = game.texture.createAnimationFromName([0, 1, 2, 3/*, 4, 5, 6, 7,*/ ]); for(var i=0;i<data.path.length;i++){ this.patrol_addPoint( new me.Vector2d(data.path.x, data.path.y)); console.log( new me.Vector2d(data.path[0].x, data.path[0].y)) } this.renderable.addAnimation( "down", [ 2 ] ); this.renderable.addAnimation( "left", [0] ); this.renderable.addAnimation( "right", [3 ] ); this.renderable.addAnimation( "up", [1] ); this.afterPatrolFinished = function(){ console.log("patrol finished"); me.game.world.removeChild(this) }; this.patrol_walk(); }, patrol_addPoint:function(point){ this.patrol_path.push(point); }, patrol_walk:function(){ this._isWalking = true; if( !this._target && this.patrol_path[ 0 ] ) { this._target = this.patrol_path[ 0 ]; } this._setDirection(this._target.x - this.pos.x, this._target.y - this.pos.y); this.renderable.setCurrentAnimation( this.direction ); }, _setDirection: function( dx, dy ) { if(dx>0&&dy<0){ this.direction = "up"; } else if(dx<0&&dy>0){ this.direction="down"; } else if(dx<0&&dy<0){ this.direction="left"; }else{ this.direction="right"; } }, update: function(dt) { if( !this._isWalking ){ return false; } this._calculateStep(); this.body.update(dt); return (this._super(me.Entity, 'update', [dt]) || this.body.vel.x !== 0 || this.body.vel.y !== 0); }, _calculateStep: function( ) { if( this._target ) { var dx = this._target.x - this.pos.x; var dy = this._target.y - this.pos.y; console.log("this.pos.x"); console.log(this.pos.x+"=="+this.pos.y); console.log(this._target); console.log(dx+"=="+dy); if( Math.abs( dx ) < this.body.maxVel.x && Math.abs( dy ) < this.body.maxVel.x ) { var idx = this.patrol_path.indexOf( this._target ); console.log(idx); //next point index idx++; if( idx == ( this.patrol_path.length ) ) { delete this._target; if(typeof this.afterPatrolFinished === 'function'){ this.afterPatrolFinished(); } if( this.patrol_isReverse ){ this.patrol_path.reverse( ); } if( this.patrol_isInfinite){ this.patrol_isInfinite = false; } } else { this._target = this.patrol_path[ idx ]; this._setDirection(this._target.x - this.pos.x, this._target.y - this.pos.y); this.renderable.setCurrentAnimation( this.direction ); } return; } var angle = Math.atan2( this._target.y - this.pos.y, this._target.x - this.pos.x ) ; this.body.vel.x = Math.cos( angle ) * this.body.accel.x+1.9 /** me.timer.tick*/; this.body.vel.y = Math.sin( angle ) * this.body.accel.y*0.5 /** me.timer.tick*/; } else { this.body.vel.x = 0; this.body.vel.y = 0; } }, /** * Stop walking */ patrol_stop: function( ) { this._isWalking = false; }, /** * Set reverse. * When is reverse, the movement is there and back * @param {boolean} */ patrol_setReverse: function( isReverse ) { this.patrol_isReverse = isReverse; }, /** * Set infinite. * When is infinite, the movement is in an endless loop * @param {boolean} */ patrol_setInfinite: function( isInfinite ) { this.patrol_isInfinite = isInfinite; }, onCollision : function (/*response, other*/) { return true; } });
  4. I wanted to plot my big 6600*13200 map fix into my viewport and my canvas size is 1000*1440 as mentioned in https://github.com/melonjs/melonJS/issues/4
  5. yeah i tried it before also its also zooming as shown in the below image. and i used me.game.world which return my tiled map and i tried to scale it then also its coming as same as below image
  6. hey guys i understand something correct me if i am wrong . here our canvas widt and height is not changing i am changing my viewport only, me.game.viewport.scale(0.5,0.5) which means the area which we are able to see its a viewport right .so i am thinking we need to update or redraw or repaint it but i am not getting where to do it please help me crak it Thank You ,I hope you guys were understanding ..
  7. @obiot i gone through that discussion it wont help me much i want to resize the currentLevel which is loaded on the canvas https://groups.google.com/forum/#!topic/melonjs/7dUEQGsutjI i gone through this also but no luck .. is their any function which i can get the map and scale it how we moving map by using me.game.viewport.move(0, (me.levelDirector.getCurrentLevel().height / 2)); like this can we use to zoom in and out the map
  8. Hi guys, i am trying to shrink my 100*100 celled isometric map to fit my desktop screen on click of a button (or through scroll event). The only possible option I have managed to get is the canvas zoom-in/out feature in melonJS. It is not suiting my requirement as the border cells are not shown inside my viewport. Could you suggest if there is any better way to do this? My current code looks something like this : // register on mouse event me.input.registerPointerEvent("wheel", me.game.viewport, function (event) { me.event.publish("wheel", [ event ]); },false); this.mousewheel = me.event.subscribe("wheel", function (event) { console.log("^^^"); var viewport = me.game.viewport; //viewport.inViewport = true; if ( event.deltaY >0 ){ console.log("scrolldown"); viewport.currentTransform.scale(0.999); console.log(jq('canvas')); }else{ console.log("scrollup"); viewport.currentTransform.scale(1.001); } });
  9. yes the update function running every frame and i want to have it in a straight line instead of sine wave.Is there any way to fix it sample code can be found here https://github.com/Kibo/melonjs-cookbook/tree/master/cookbook/patrol/js for patrol.
  10. so far i am doing good with patrol thing but i struct at giving Velocity. car is moving on the road but its not going straight , its going in zigzag way within the road but i want it to go straight along with the road this is the code which i am using to give velocity var dx = this._target.x - this.pos.x; var dy = this._target.y - this.pos.y; var angle = Math.atan2( dy, dx ) ; //var angle = Math.atan2( dx, dy ) ; console.log( Math.cos( angle )); this.body.vel.x = Math.cos( angle ) * this.body.accel.x * me.timer.tick; this.body.vel.y = Math.sin( angle ) * this.body.accel.y * me.timer.tick; //alternate way of setting velocity....... // this.body.vel.x = dx.clamp(-1, 1) * this.body.accel.x; // this.body.vel.y = dy.clamp(-1,1) * this.body.accel.y; }
  11. HI guys, Our City game is progressing well . Now I wanted to animate cars to ply on the roads which is created by the players in the game. After creating the roads i want the car to move on the same road, The roads are created by clicking each tile by the user. The entire road length is saved in a array. I need the cars to move from starting point of my road to end point of road where the user has plotted. can some one tell me what method i can use to achieve this, for now I am trying with https://github.com/Kibo/melonjs-cookbook/tree/master/cookbook/patrol/js patrol method. I am having trouble with my co-ordinates because patrol is in 2d but my game is in isometric , And If I move or pan the screen car was not sticking with my game world rather its taking the browser screen. tried using functions like .toiso(),localToWorld() . But of no luck can some one tell me is their any other way to achieve it or solution for this. Thank you HAPPY GAMING...
  12. hi @01271 you try this it will come this._super(me.Sprite, 'init', [339, 480, settings]); this.addAnimation('normal',[{ name: 0, delay: 600 }, { name: 1, delay: 600 },{name: 2, delay: 600 },{name: 3, delay: 600 },{name: 4, delay: 600 },{name: 5, delay: 600 },{name: 6, delay: 600 },{name: 7, delay: 600 },{name: 8, delay: 600 },{name: 9, delay: 600 }]); this.setCurrentAnimation('normal'); give delay how much you want.
  13. yeah you guys right but if i am using me.Entity the dragging functionalities is not so smooth as in me.DraggableEntity so i am sticking with DraggableEntity only ..
  14. no i am not getting it. i am just changing this.getBounds().height=200; i dont know syntax is correct or not.