@m2c2kit/core 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -72,13 +72,16 @@ declare class GlobalVariables {
72
72
 
73
73
  declare global {
74
74
  var Globals: GlobalVariables;
75
- }
75
+ }
76
+ //# sourceMappingURL=Globals.d.ts.map
76
77
 
77
78
  /**
78
79
  * Position in two-dimensional space.
79
80
  */
80
81
  declare class Point {
82
+ /** Horizonal coordinate */
81
83
  x: number;
84
+ /** Vertical coordinate */
82
85
  y: number;
83
86
  constructor(x?: number, y?: number);
84
87
  }
@@ -98,15 +101,25 @@ interface TapEvent {
98
101
  }
99
102
 
100
103
  interface Constraints {
104
+ /** Constrain the top (vertical axis) of this entity to the top of the specified entity. The tops of both will appear at the same vertical location */
101
105
  topToTopOf?: Entity | string;
106
+ /** Constrain the top (vertical axis) of this entity to the bottom of the specified entity. This entity will appear immediately below the specified entity */
102
107
  topToBottomOf?: Entity | string;
108
+ /** Constrain the bottom (vertical axis) of this entity to the top of the specified entity. This entity will appear immediately above of the specified entity */
103
109
  bottomToTopOf?: Entity | string;
110
+ /** Constrain the bottom (vertical axis) of this entity to the bottom of the specified entity. The bottoms of both will appear at the same vertical location */
104
111
  bottomToBottomOf?: Entity | string;
112
+ /** Constrain the start (horizontal axis) of this entity to the start of the specified entity. The start of both will appear at the same horizontal location */
105
113
  startToStartOf?: Entity | string;
114
+ /** Constrain the start (horizontal axis) of this entity to the end of the specified entity. This entity will appear immediately to the right of the specified entity */
106
115
  startToEndOf?: Entity | string;
116
+ /** Constrain the end (horizontal axis) of this entity to the end of the specified entity. The end of both will appear at the same horizontal location */
107
117
  endToEndOf?: Entity | string;
118
+ /** Constrain the end (horizontal axis) of this entity to the start of the specified entity. This entity will appear immediately to the left of the specified entity */
108
119
  endToStartOf?: Entity | string;
120
+ /** When opposing horizontal constraints are applied, the default is to center the entity within the constraints (horizontalBias = .5). Setting horizontalBias less than .5 will pull the entity towards the start (to the left). Setting horizontalBias greater than .5 will pull the entity towards the end (to the right) */
109
121
  horizontalBias?: number;
122
+ /** When opposing vertical constraints are applied, the default is to center the entity within the constraints (verticalBias = .5). Setting verticalBias less than .5 will pull the entity towards the top. Setting verticalBias greater than .5 will pull the entity towards the bottom */
110
123
  verticalBias?: number;
111
124
  [key: string]: Entity | string | number | undefined;
112
125
  }
@@ -136,11 +149,17 @@ declare class Size {
136
149
  }
137
150
 
138
151
  interface EntityOptions {
152
+ /** Name of the entity. Only needed if the entity will be referred to by name in a later function */
139
153
  name?: string;
154
+ /** Position of the entity within its parent coordinate system. Default is (0, 0) */
140
155
  position?: Point;
156
+ /** Scale of the entity. Default is 1.0 */
141
157
  scale?: number;
158
+ /** Does the entity respond to user events, such as taps? Default is false */
142
159
  isUserInteractionEnabled?: boolean;
160
+ /** Is the entity, and its children, hidden? (not displayed). Default is false */
143
161
  hidden?: boolean;
162
+ /** FOR INTERNAL USE ONLY */
144
163
  layout?: Layout;
145
164
  }
146
165
 
@@ -155,7 +174,7 @@ declare enum EntityType {
155
174
  }
156
175
 
157
176
  declare function handleInterfaceOptions(entity: Entity, options: EntityOptions): void;
158
- declare abstract class Entity {
177
+ declare abstract class Entity implements EntityOptions {
159
178
  type: EntityType;
160
179
  isDrawable: boolean;
161
180
  isShape: boolean;
@@ -214,6 +233,12 @@ declare abstract class Entity {
214
233
  * Returns all descendant entities. Descendants are children and children of children, recursively.
215
234
  */
216
235
  get descendants(): Array<Entity>;
236
+ /**
237
+ * Provides the callback function to be executed when the user taps the entity.
238
+ *
239
+ * @param codeCallback - function to execute
240
+ * @param replaceExistingCodeCallback - should the provided callback replace any existing callbacks? Usually we want to have only one callback defined, instead of chaining multiple ones. It is strongly recommended not to change this, unless you have a special use case. Default is true.
241
+ */
217
242
  onTap(codeCallback: (tapEvent: TapEvent) => void, replaceExistingCodeCallback?: boolean): void;
218
243
  private parseLayoutConstraints;
219
244
  private calculateYFromConstraint;
@@ -480,10 +505,11 @@ declare enum Dimensions {
480
505
  }
481
506
 
482
507
  interface SceneOptions extends EntityOptions, DrawableOptions {
508
+ /** Background color of the scene. Default is Constants.DEFAULT_SCENE_BACKGROUND_COLOR (WebColors.WhiteSmoke) */
483
509
  backgroundColor?: RgbaColor;
484
510
  }
485
511
 
486
- declare class Scene extends Entity implements IDrawable {
512
+ declare class Scene extends Entity implements IDrawable, SceneOptions {
487
513
  readonly type = EntityType.scene;
488
514
  isDrawable: boolean;
489
515
  anchorPoint: Point;
@@ -499,8 +525,7 @@ declare class Scene extends Entity implements IDrawable {
499
525
  *
500
526
  * @remarks The scene is the game screen or stage, and fills the entire available screen. There are usually multiple screens to contain multiple stages of the game, such as various instruction pages or phases of a game.
501
527
  *
502
- * @param options
503
- * @see {@link SceneOptions}
528
+ * @param options - {@link SceneOptions}
504
529
  */
505
530
  constructor(options?: SceneOptions);
506
531
  initialize(): void;
@@ -522,6 +547,13 @@ declare class Scene extends Entity implements IDrawable {
522
547
  declare abstract class Transition {
523
548
  abstract type: TransitionType;
524
549
  duration: number;
550
+ /**
551
+ * Creates a scene transition in which the outgoing scene slides out and the incoming scene slides in, as if the incoming scene pushes it.
552
+ *
553
+ * @param direction - TransitionDirection in which the push action goes
554
+ * @param duration - Duration, in millis, of the transition
555
+ * @returns
556
+ */
525
557
  static push(direction: TransitionDirection, duration: number): PushTransition;
526
558
  }
527
559
  declare class PushTransition extends Transition {
@@ -636,15 +668,20 @@ declare class Game {
636
668
  * at the appropriate time. It is not triggered automatically.
637
669
  * @param codeCallback
638
670
  */
639
- onAllTrialsComplete(codeCallback: (data: GameData) => void): void;
671
+ onAllTrialsComplete(codeCallback: (data: GameData, trialSchema: object) => void): void;
640
672
  /**
641
673
  * Adds a scene to the game.
642
674
  *
643
- * @remarks A scene, and its children entities, cannot be preseneted unless it has been added to the game object.
675
+ * @remarks A scene, and its children entities, cannot be presented unless it has been added to the game object.
644
676
  *
645
677
  * @param scene
646
678
  */
647
679
  addScene(scene: Scene): void;
680
+ /**
681
+ * Adds multiple scenes to the game.
682
+ *
683
+ * @param scenes
684
+ */
648
685
  addScenes(scenes: Array<Scene>): void;
649
686
  /**
650
687
  * Specifies the scene that will be presented upon the next frame draw.
@@ -669,6 +706,14 @@ declare class Game {
669
706
  */
670
707
  start(entryScene?: Scene | string): void;
671
708
  initData(trialSchema: object): void;
709
+ /**
710
+ * Adds data to the game's TrialData object.
711
+ *
712
+ * @remarks The variableName must be previously defined in the trialSchema object passed in during game initialization. see {@link GameInitOptions.trialSchema}. The type of the value must match what was defined in the trialSchema, otherwise an error is thrown.
713
+ *
714
+ * @param variableName - variable to be set
715
+ * @param value - value of the variable to set
716
+ */
672
717
  addTrialData(variableName: string, value: any): void;
673
718
  private loadCanvasKit;
674
719
  private setupHtmlCanvases;
@@ -716,9 +761,13 @@ interface IText {
716
761
  }
717
762
 
718
763
  interface TextOptions {
764
+ /** Text to be displayed */
719
765
  text?: string;
766
+ /** Name of font to use for text. Must have been previously loaded */
720
767
  fontName?: string;
768
+ /** Color of text. Default is Constants.DEFAULT_FONT_COLOR (WebColors.Black) */
721
769
  fontColor?: RgbaColor;
770
+ /** Size of text. Default is Constants.DEFAULT_FONT_SIZE (16) */
722
771
  fontSize?: number;
723
772
  }
724
773
 
@@ -729,12 +778,15 @@ declare enum LabelHorizontalAlignmentMode {
729
778
  }
730
779
 
731
780
  interface LabelOptions extends EntityOptions, DrawableOptions, TextOptions {
781
+ /** Horizontal alignment of label text. see {@link LabelHorizontalAlignmentMode}. Default is LabelHorizontalAlignmentMode.center */
732
782
  horizontalAlignmentMode?: LabelHorizontalAlignmentMode;
783
+ /** Maximum width of label text before wrapping occurs. Default is the canvas width */
733
784
  preferredMaxLayoutWidth?: number;
785
+ /** Background color of label text. Default is no background color */
734
786
  backgroundColor?: RgbaColor;
735
787
  }
736
788
 
737
- declare class Label extends Entity implements IDrawable, IText {
789
+ declare class Label extends Entity implements IDrawable, IText, LabelOptions {
738
790
  readonly type = EntityType.label;
739
791
  isDrawable: boolean;
740
792
  isText: boolean;
@@ -752,9 +804,9 @@ declare class Label extends Entity implements IDrawable, IText {
752
804
  /**
753
805
  * Single or multi-line text formatted and rendered on the screen.
754
806
  *
755
- * @remarks Label (in contrast to TextLine) has enhanced text support for line wrapping, centering/alignment, and background colors.
807
+ * @remarks Label (in contrast to TextLine) has enhanced text support for line wrapping, centering/alignment, and background colors.
756
808
  *
757
- * @param options
809
+ * @param options - {@link LabelOptions}
758
810
  */
759
811
  constructor(options?: LabelOptions);
760
812
  initialize(): void;
@@ -825,11 +877,17 @@ declare class RandomDraws {
825
877
  }
826
878
 
827
879
  interface RectOptions {
880
+ /** Position of rectangle */
828
881
  origin?: Point;
882
+ /** Size of rectangle */
829
883
  size?: Size;
884
+ /** X coordinate of rectangle position; this can be used instead of setting the origin property */
830
885
  x?: number;
886
+ /** Y coordinate of rectangle position; this can be used instead of setting the origin property */
831
887
  y?: number;
888
+ /** Width of rectangle; this can be used instead of setting the size property */
832
889
  width?: number;
890
+ /** Height of rectangle; this can be used instead of setting the size property */
833
891
  height?: number;
834
892
  }
835
893
 
@@ -844,11 +902,17 @@ declare class Rect implements RectOptions {
844
902
  }
845
903
 
846
904
  interface ShapeOptions extends EntityOptions, DrawableOptions {
905
+ /** If provided, shape will be a circle with given radius */
847
906
  circleOfRadius?: number;
907
+ /** If provided, shape will be a rectangle as specified in {@link Rect} */
848
908
  rect?: Rect;
909
+ /** Radius of rectangle's corners */
849
910
  cornerRadius?: number;
911
+ /** Color with which to fill shape. Default is Constants.DEFAULT_SHAPE_FILL_COLOR (WebColors.Red) */
850
912
  fillColor?: RgbaColor;
913
+ /** Color with which to outline shape. Default is no color */
851
914
  strokeColor?: RgbaColor;
915
+ /** Width of outline. Default is undefined */
852
916
  lineWidth?: number;
853
917
  }
854
918
 
@@ -858,7 +922,7 @@ declare enum ShapeType {
858
922
  circle = "Circle"
859
923
  }
860
924
 
861
- declare class Shape extends Entity implements IDrawable {
925
+ declare class Shape extends Entity implements IDrawable, ShapeOptions {
862
926
  readonly type = EntityType.shape;
863
927
  isDrawable: boolean;
864
928
  isShape: boolean;
@@ -874,9 +938,9 @@ declare class Shape extends Entity implements IDrawable {
874
938
  private fillColorPaint?;
875
939
  private strokeColorPaint?;
876
940
  /**
877
- * Rectangular shape
941
+ * Rectangular or circular shape
878
942
  *
879
- * @param options
943
+ * @param options - {@link ShapeOptions}
880
944
  */
881
945
  constructor(options?: ShapeOptions);
882
946
  initialize(): void;
@@ -889,10 +953,11 @@ declare class Shape extends Entity implements IDrawable {
889
953
  }
890
954
 
891
955
  interface SpriteOptions extends EntityOptions, DrawableOptions {
956
+ /** Name of image to use for sprite. Must have been previously loaded */
892
957
  imageName?: string;
893
958
  }
894
959
 
895
- declare class Sprite extends Entity implements IDrawable {
960
+ declare class Sprite extends Entity implements IDrawable, SpriteOptions {
896
961
  readonly type = EntityType.sprite;
897
962
  isDrawable: boolean;
898
963
  anchorPoint: Point;
@@ -904,7 +969,7 @@ declare class Sprite extends Entity implements IDrawable {
904
969
  *
905
970
  * @remarks Sprites must be loaded during the Game.init() method prior to their use.
906
971
  *
907
- * @param options
972
+ * @param options - {@link SpriteOptions}
908
973
  */
909
974
  constructor(options?: SpriteOptions);
910
975
  initialize(): void;
@@ -926,7 +991,7 @@ interface TextLineOptions extends EntityOptions, DrawableOptions, TextOptions {
926
991
  width?: number;
927
992
  }
928
993
 
929
- declare class TextLine extends Entity implements IDrawable, IText {
994
+ declare class TextLine extends Entity implements IDrawable, IText, TextLineOptions {
930
995
  readonly type = EntityType.textline;
931
996
  isDrawable: boolean;
932
997
  isText: boolean;
@@ -943,7 +1008,7 @@ declare class TextLine extends Entity implements IDrawable, IText {
943
1008
  *
944
1009
  * @remarks TextLine has no paragraph formatting options; Label will be preferred in most use cases.
945
1010
  *
946
- * @param options
1011
+ * @param options - {@link TextLineOptions}
947
1012
  */
948
1013
  constructor(options?: TextLineOptions);
949
1014
  get text(): string;
@@ -1122,4 +1187,4 @@ declare class WebColors {
1122
1187
  static RebeccaPurple: RgbaColor;
1123
1188
  }
1124
1189
 
1125
- export { Action, Composite, CompositeOptions, Constants, ConstraintType, Constraints, CustomAction, CustomActionOptions, Dimensions, DrawableOptions, Entity, EntityOptions, EntityType, FontData, FontManager, Game, GameInitOptions, GlobalVariables, GroupAction, IDrawable, IText, ImageManager, Label, LabelHorizontalAlignmentMode, LabelOptions, Layout, LayoutConstraint, LoadedImage, MoveAction, MoveActionOptions, Point, PushTransition, RandomDraws, Rect, RectOptions, RgbaColor, ScaleAction, ScaleActionOptions, Scene, SceneOptions, SceneTransition, SequenceAction, Shape, ShapeOptions, ShapeType, Size, Sprite, SpriteOptions, Story, StoryOptions, SvgImage, TapEvent, TapListener, TextLine, TextLineOptions, TextOptions, Timer, Transition, TransitionDirection, TransitionType, WaitAction, WaitActionOptions, WebColors, handleInterfaceOptions };
1190
+ export { Action, Composite, CompositeOptions, Constants, ConstraintType, Constraints, CustomAction, CustomActionOptions, Dimensions, DrawableOptions, Entity, EntityOptions, EntityType, FontData, FontManager, Game, GameData, GameInitOptions, GlobalVariables, GroupAction, IDrawable, IText, ImageManager, Label, LabelHorizontalAlignmentMode, LabelOptions, Layout, LayoutConstraint, LoadedImage, MoveAction, MoveActionOptions, Point, PushTransition, RandomDraws, Rect, RectOptions, RgbaColor, ScaleAction, ScaleActionOptions, Scene, SceneOptions, SceneTransition, SequenceAction, Shape, ShapeOptions, ShapeType, Size, Sprite, SpriteOptions, Story, StoryOptions, SvgImage, TapEvent, TapListener, TextLine, TextLineOptions, TextOptions, Timer, Transition, TransitionDirection, TransitionType, WaitAction, WaitActionOptions, WebColors, handleInterfaceOptions };