define the location of pictures in a 2 by 2 grid
Hello everyone,
I have a 2 by 2 grid, in which I want two pictures to be presented simulataneously: one always left and one always right. Also, I want a red cirkle to appear on the same place as either the left or the right picture.
The grid is drawn in this way:
| grid | = new Sprite(); | ||||
| grid.x | = stage.stageWidth | * .5; | |||
| grid.y | = stage.stageHeight | * .5; | |||
| with( grid.graphics ){ | |||||
| lineStyle( 10, 0x000000 ); | |||||
| moveTo( -250, -250 ); | |||||
| lineTo( -250, 250 ); | |||||
| moveTo( -250, 250 ); | |||||
| lineTo( 250, 250 ); | |||||
| moveTo( 250, 250 ); | |||||
| lineTo( 250, -250 ); | |||||
| moveTo( 250, -250 ); | |||||
| lineTo( -250, -250 ); | |||||
| moveTo( 0, -250 ); | |||||
| lineTo( 0, 250 ); | |||||
| moveTo( -250, 0 ); | |||||
| lineTo( 250, 0 ); | |||||
| } |
The upper-left-quartile of the gird: I call Q1
The upper-right is Q2
The lower-left is Q3
The lower-right is Q4
I want to define the location of the stimuli like this:
switch( leftStimulusLocation ) {
case Q1: leftStimulus.x = ...; leftStimulus.y = ...; break;
case Q3: leftStimulus.x = ...; leftStimulus.y = ...; break;
}
switch( rightStimulusLocation ) {
case Q2: rightStimulus.x = ...; rightStimulus.y = ...; break;
case Q4: rightStimulus.x = ...; rightStimulus.y = ...; break;
}
// determine x and y coordinates of selector based on location (Q1/Q2/Q3/Q4)
switch( selectorLocation ) {
case Q1: selector.x = ...; selector.y = ...; break;
case Q2: selector.x = ...; selector.y = ...; break;
case Q3: selector.x = ...; selector.y = ...; break;
case Q4: selector.x = ...; selector.y = ...; break;
}
The selector is the red cirkle that I use.
I cannot seem to figure out the right coordinates for the different quartiles. I want the pictures to be displayed exactly in the center of the quartile of the grid.
Also, I need the coordinates to be relative to the stage or grid instead of absolute, so the location won't change if I, for example, change the size of the grid.
I figured out that the pictures are added to the stage with their left uppercorner as reference point, but the cirkle (which I also have drawn using the graphics class) has its center as reference point. So I will need different coordinates for this.
Can someone help me?
With kind regards,
Johanna Quist
