Jump to content

Search the Community

Showing results for tags 'phaser drag run'.

  • 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. I need to make a game where dragging commands I give the path by which character will to move forward, left, right. I do not know how to remember the id command forward, left, right in a sequence/array komande, after which I can start the run and thrown such a way that the character moves ? var game = new Phaser.Game("100%","100%",Phaser.CANVAS,"",{ preload:onPreload, create:onCreate, resize:onResize }); var GlavniKarakter = { 'X':4, 'Y':2, 'Sifra':2, 'pravac':1 // 1 move, 2 right, 3 left }; //matrix var level = [[1,1,1,1,1,1,1,1], [1,0,0,1,1,1,1,1], [1,0,0,1,1,1,1,1], [1,0,0,0,0,0,0,1], [1,1,2,1,1,1,0,1], [1,0,0,0,1,0,0,1], [1,0,0,0,1,1,1,1], [1,1,1,1,1,1,1,1]]; // array from run var komande = []; function onPreload() { game.stage.backgroundColor = "#FDD267"; game.load.spritesheet("polja","polja.png",40,40); game.load.spritesheet("zid","zid.png",40,40); game.load.spritesheet("igrac","igrac.png",40,40); game.load.spritesheet("move","move.png",53,23);//move game.load.spritesheet("right","desno.png",53,43);//right game.load.spritesheet("left","levo.png",53,43);//left game.load.spritesheet("run","run.png",45,45);//run } function onCreate() { // copy command, when you drag and drop for(var j = 0; j<3;j++){ moveForward= game.add.sprite(350, 30*1,'move',1); moveForward.inputEnabled = true; moveForward.input.enableDrag(); moveForward.input.enableSnap(350, 30, false, true); //komande.push(1); } this.game.time.events.add(350, function() { if (this.game.input.activePointer.isDown) { moveForward.input.startDrag(this.game.input.activePointer); }komande.push(1); // array from command }, this); for(var j = 0; j<3;j++){ var moveRight = game.add.sprite(350, 30 * 2, 'right', 2); // moveRight-turn rught moveRight.inputEnabled = true; moveRight.input.enableDrag(); moveRight.input.enableSnap(350, 30, false, true); this.game.time.events.add(350, function() { if (this.game.input.activePointer.isDown) { moveRight.input.startDrag(this.game.input.activePointer); } komande.push(2); }, this); } // moveLeft-turn Left for(var j = 0; j<3;j++){ moveLeft = game.add.sprite(350, 30 * 3, 'left', 3); moveLeft.inputEnabled = true; moveLeft.input.enableDrag(); moveLeft.input.enableSnap(350, 30, false, true); this.game.time.events.add(350, function() { if (this.game.input.activePointer.isDown) { moveLeft.input.startDrag(this.game.input.activePointer); } komande.push(3); }, this); } dgmRun=game.add.sprite(350,120,'run'); dgmRun.inputEnabled = true; crtajLavirint(); //moveForward.events.onInputDown.add(dada, this); //moveRight.events.onInputDown.add(okretDesno, this); //moveLeft.events.onInputDown.add(okretLevo, this); dgmRun.events.onInputDown.add(runKomande, this); igrac =game.add.sprite(40*GlavniKarakter.Y,40*GlavniKarakter.X,"igrac"); } /* functions that are created but not to letters*/ //function runForward // function runLeft //functio runRight // function run, execute array komande function runKomande(){ for(var k=0;k<komande.length;k++){ if(komande[k]==1) runForward(); if(komande[k]==2) runRight(); if(komande[k]==3) runLeft(); //crtajLavirint(); } }
×
×
  • Create New...