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

Limit movement of symbol along axis

Engaged ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

I have a graphic symbol being moved along the X axis programmatically via button press.

 

How can I limit the movement of that symbol to a certain point on the stage, e.g. along X axis?

 

I assume I can get the position of the symbol like:

 

var leftFrame_X = this.LeftFrame.x;

 

Is that position different from the x position shown in properties?

 

How would I test for that position and stop the symbol from moving further in that direction?

 

Like this?

 

function updateLF_Move_Right(){

	if(leftFrame_X != leftFrame_X){
root.LeftFrame.x+=1
	} else {
root.LeftFrame.x+=0
}

 

This is the code I currently have:

 

this.ButtonLeftFrameMoveRight.addEventListener("mousedown", LF_MoveRight_Down.bind(this));
this.ButtonLeftFrameMoveRight.addEventListener("pressup", LF_MoveRight_Up.bind(this));

var frameLeft = this;

function LF_MoveRight_Down() {
    
createjs.Ticker.addEventListener("tick",updateLF_Move_Right);
    
}

function LF_MoveRight_Up() {

createjs.Ticker.removeEventListener("tick",updateLF_Move_Right);

}

function updateLF_Move_Right(){

frameLeft.LeftFrame.x+=1

}

 

 

Views

123

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

correct answers 1 Correct answer

Engaged , Feb 13, 2022 Feb 13, 2022

Sorted:

 

function updateLF_Move_Right(){
	if(root.LeftFrame.x <= 597.3){	
root.LeftFrame.x+=1;
	}
}

function updateLF_Move_Left(){
if(root.LeftFrame.x >= 508.3){	
root.LeftFrame.x-=1
}	
}

Votes

Translate

Translate
Engaged ,
Feb 11, 2022 Feb 11, 2022

Copy link to clipboard

Copied

That shoul read:

 

if(leftFrame_X != some pos X){

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
Engaged ,
Feb 13, 2022 Feb 13, 2022

Copy link to clipboard

Copied

LATEST

Sorted:

 

function updateLF_Move_Right(){
	if(root.LeftFrame.x <= 597.3){	
root.LeftFrame.x+=1;
	}
}

function updateLF_Move_Left(){
if(root.LeftFrame.x >= 508.3){	
root.LeftFrame.x-=1
}	
}

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