Skip to main content
Participating Frequently
Apr 20, 2024 10:10 AM UTC
Answered

doesn't work on a mobile screen

Hello, does anyone know how to make the touch screen react to pressing an object? ? )) Here is the function for the mouse and desktop on primer (in Adobe Animated) - this.ball.on("pressmove", moveBall ); . But it doesn't work on a mobile screen. Is there an alternative? Just not a click, but a constant click on an object is read

    This topic is closed to new replies. Start a new post to keep the conversation going.
    JoãoCésar17023019
    JoãoCésar17023019Correct answer
    Community Expert
    Apr 20, 2024 2:21 PM UTC

    There isn't any specifically for mobile, as far as I can tell.

     

    But the official documentation for CreateJS is at createjs.com.

    9 replies

    JoãoCésar17023019
    Community Expert
    Community Expert
    Apr 20, 2024 2:14 PM UTC

    Hi.

     

    Please make sure you're enabling touch interactions by calling...

    createjs.Touch.enable(stage);


    ... in the beginning of your code.

    Regards,
    JC

    Translate
    Participating Frequently
    Apr 20, 2024 2:17 PM UTC

    Thank you. Please tell me, is there a link to the documentation that describes all the commands when working with canvas on a touch screen?

    Translate
    JoãoCésar17023019
    Community Expert
    JoãoCésar17023019Community ExpertCorrect answer
    Community Expert
    Apr 20, 2024 2:21 PM UTC

    There isn't any specifically for mobile, as far as I can tell.

     

    But the official documentation for CreateJS is at createjs.com.

    Translate
    kglad
    Community Expert
    Community Expert
    Apr 20, 2024 1:43 PM UTC

    i don't see a problem.

    Translate
    Participating Frequently
    Apr 20, 2024 2:12 PM UTC

    I'm sorry. Attached  -  fla and example code. 

    I repeat. Everything works fine on a desktop with mouse controls, but does not work on a mobile device with a touch screen. Can you tell me what to do?

     

    var root = this;
    this.yes.visible=false;
    this.ball.on("pressmove", moveBall );
    
    function moveBall(e) {
    		var p = stage.globalToLocal(e.stageX, e.stageY)
    		e.currentTarget.x= p.x;
    		e.currentTarget.y= p.y;
    	
    }
    
    this.ball.on("pressup", dropBall);
    
    var myN=0;
    
    function dropBall () {
    	
    	if(root.ball.x>85 && root.ball.x < 1180 && root.ball.y > 65 && root.ball.y < 365 ) {
    		root.ball.alpha=0.5;
    		root.ball.x=root.myRect.x;
    		root.ball.y=root.myRect.y;
    		root.yes.visible=true;
    		myN++
    		if(myN>5) {
    			root.ball.visible=false;
    		}
    	} else {
    		root.ball.alpha=1;
    		root.yes.visible=false;
    	}
    		
    	
    }

     

    Translate