2015-12-13 6 views
5

मैंने समस्या को दोहराने के लिए एक छोटी परीक्षा परियोजना बनाई है। परियोजना इस उदाहरण से केवल pixi.min.js और कोड के साथ index.html शामिल हैं:इंटेल-एक्सडीके फाइलों को धक्का देने के बाद आईफोन पर पिक्सी.जेएस टच इवेंट नहीं फायरिंग

http://pixijs.github.io/examples/index.html?s=demos&f=interactivity.js&title=Interactivity

बटन काम जब मैं यह ब्राउज़र के माध्यम से परीक्षण करें। वे intel-xdkemulate टैब में भी काम करते हैं।

लेकिन जब मैं test टैब पर जाता हूं, फ़ाइलों को पुश करता हूं, आईफोन पर बनाए गए ऐप को खोलने के लिए क्यूआर कोड स्कैन करता हूं, बटन दिखाई देते हैं लेकिन टच इवेंट काम नहीं कर रहे हैं।

आईफोन पर टच इवेंट क्यों नहीं चल रहे हैं?

<!DOCTYPE html> 
<html lang="en"> 
<head> 
    <meta charset="UTF-8"> 
</head> 
<body style="margin:0; padding: 0; background: #333333;"> 
    <script src="pixi.min.js"></script> 
    <script> 
     var renderer = PIXI.autoDetectRenderer(800, 600); 
     document.body.appendChild(renderer.view); 

     var stage = new PIXI.Container(); 

     var textureButton = PIXI.Texture.fromImage('images/button.png'); 
     var textureButtonDown = PIXI.Texture.fromImage('images/button.png'); 
     var textureButtonOver = PIXI.Texture.fromImage('images/button2.png'); 

     var buttons = []; 

     var buttonPositions = [ 
      175, 75, 
      655, 75, 
      410, 325, 
      150, 465, 
      685, 445 
     ]; 

     var noop = function() { 
      //console.log('click'); 
     }; 

     for (var i = 0; i < 5; i++) 
     { 
      var button = new PIXI.Sprite(textureButton); 
      button.buttonMode = true; 

      button.anchor.set(0.5); 

      button.position.x = buttonPositions[i*2]; 
      button.position.y = buttonPositions[i*2 + 1]; 
      button.interactive = true; 

      button.on('mousedown', onButtonDown) 
       .on('touchstart', onButtonDown) 
       .on('mouseup', onButtonUp) 
       .on('touchend', onButtonUp) 
       .on('mouseupoutside', onButtonUp) 
       .on('touchendoutside', onButtonUp) 
       .on('mouseover', onButtonOver) 
       .on('mouseout', onButtonOut); 

      button.tap = noop; 
      button.click = noop; 
      stage.addChild(button); 
      buttons.push(button); 
     } 
     buttons[0].scale.set(1.2); 
     buttons[2].rotation = Math.PI/10; 
     buttons[3].scale.set(0.8); 
     buttons[4].scale.set(0.8,1.2); 
     buttons[4].rotation = Math.PI; 

     animate(); 

     function animate() { 
      renderer.render(stage); 
      requestAnimationFrame(animate); 
     } 

     function onButtonDown(){ 
      this.isdown = true; 
      this.texture = textureButtonDown; 
      this.alpha = 1; 
     } 

     function onButtonUp(){ 
      this.isdown = false; 
      if (this.isOver){ this.texture = textureButtonOver; 
      }else{ this.texture = textureButton; } 
     } 

     function onButtonOver(){ 
      this.isOver = true; 

      if (this.isdown){ 
       return; 
      } 
      this.texture = textureButtonOver; 
     } 

     function onButtonOut(){ 
      this.isOver = false; 
      if (this.isdown){ return; } 
      this.texture = textureButton; 
     } 
    </script> 
</body> 
</html> 
+0

पर काम करके 'काम नहीं कर रहा' देखेंगे, क्या आपका मतलब कुछ भी नहीं होता है जब आप उन्हें नल? – Karmacon

+0

हां, घटनाएं फायरिंग नहीं कर रही हैं। मैंने सवाल को सही किया। –

+0

छवियां कहां हैं? उनके माप क्या हैं? button.png और button2.png – krisrak

उत्तर

2
var textureButton = PIXI.Texture.fromImage('images/button.png'); 
var textureButtonDown = PIXI.Texture.fromImage('images/button.png'); 
var textureButtonOver = PIXI.Texture.fromImage('images/button2.png'); 

यह iPhone पर काम कर रहा है, लेकिन आप नहीं देख रहे हैं कुछ भी हो कारण आप प्रारंभिक बटन छवि textureButton और textureButtonDown ही (button.png) है। तो जब आप उस पर छूते हैं तो आपको स्क्रीन पर कोई फर्क नहीं पड़ता है। iPhone पर स्पर्श घटना के लिए कोई hover घटना होती है, तो textureButtonOver

लागू नहीं होती है लेकिन जब यू एमुलेटर पर परीक्षण करने पर आपको माउस का उपयोग कर रहे हैं, इसलिए जब यू बटन textureButtonOver लागू किया जाता है पर माउस ले जाएँ और यू परिवर्तन देख स्क्रीन पर।

तो एक अलग छवि (button3.png) को textureButtonDown बदल सकते हैं और यू यह iPhone

+0

मैंने अभी आपके कोड का उपयोग किया है और बटन 3.png बदल दिया है और यह मेरे आईफोन – krisrak

+1

पर काम करता है यह बहुत अच्छा है। मुझे यकीन नहीं है कि मैंने इसे कैसे याद किया है :) आपकी मदद के लिए धन्यवाद। –

संबंधित मुद्दे