• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

HTML5 Canvas, Function Works On Desktop, But Not iPad

Contributor ,
Apr 18, 2020 Apr 18, 2020

Copy link to clipboard

Copied

Hello,

I have a function, addAircraft.  In that function, a graphic is added to an array object, and that object has an addEventListener "click" event that goes to a sub-function, selected.  When the object is clicked, the selected function is triggered, doing a bunch of code.

This process works on desktop machines, but it does not work on the iPad.  On the iPad, when I tap the object, nothing happens.

I am using createjs.Touch.enable(stage); at the top.  Does anyone have an idea why the selected sub-function works on a Desktop, but not iPad or touch devices?

createjs.Touch.enable(stage);

// ...a bunch of code ...

function addAircraft(aircraftFilename) {
	// --- Load external aircraft graphic, put it into an array object, and add it to the stage
	var imageLoader = new createjs.LoadQueue(false, null, true);
	imageLoader.loadManifest([{id:"loadID", src:imagesPath + "/" + aircraftFilename+".svg", type:"image"}]);

	imageLoader.addEventListener("complete", loadCompleteHandler);
	
	function loadCompleteHandler(e) {
		asa.push("");
		asa[asa.length-1] = new createjs.Bitmap(e.currentTarget.getResult("loadID"));
		hangarStage.boundingBox.addChild(asa[asa.length-1]);
		
		asa[asa.length-1].aircraftObject = imageLoader;
		
		// --- Make airplane selectable
		asa[asa.length-1].addEventListener("click", selected.bind(this));
	}
	
	// When aircraft graphic is clicked, make it the selectedAircraft
	function selected (e) { //THIS ONLY WORKS ON DESKTOP MACHINES WHEN CLICKED -- IPAD/CHROME DOESN'T WORK: NOTHING HAPPENS WHEN YOU TAP THE OBJECT
		selectedAircraft = e.target;
						
		// Do a bunch of code here, such as change the tint color of selectedAircraft
	}
}

Views

222

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 19, 2020 Apr 19, 2020

Copy link to clipboard

Copied

don't use click on touch devices.  use mousedown.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Apr 19, 2020 Apr 19, 2020

Copy link to clipboard

Copied

Hi klad, thank you -- I'll try this!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Apr 20, 2020 Apr 20, 2020

Copy link to clipboard

Copied

LATEST

you're welcome.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines