diff --git a/docs/source/api/animation.rst b/docs/source/api/animation.rst new file mode 100644 index 0000000..93da8df --- /dev/null +++ b/docs/source/api/animation.rst @@ -0,0 +1,483 @@ +animation +========= + +API for creating animation + +Content +####### + + - ``animation`` - information on a animation + - ``animation.track`` - information on how animation tracks work + - ``animation.key`` - information on how animation key frames work + - ``animation.easing`` - information on how animation easing work + +Animation +######### + +.. lua:class:: animation + + .. code-block:: lua + :caption: How to create an animation + + local ball = { x = 0, y = 3, col = color.red } + + newAnimation = animation(ball) + + newTrack = newAnimation.col -- creates a animation track using the property "col" + newTrack2 = newAnimation:property("y") -- another way to create an animation track using the property "y" + + newAnimation:play() + + -- every frame + newAnimation:update() + + .. lua:method:: constructor (target) + + The constructor of the animation class + + :param target: The target table or userdata of the animation + :type target: table or userdata + + :return: A new animation + :rtype: animation + + .. helptext:: the constructor of the animation class + + .. lua:attribute:: id: number + + Sets/gets the animation's identifier + + .. helptext:: the animation's identifier + + .. lua:attribute:: name: string + + .. helptext:: the animation's name + + .. lua:method:: property(propertyName) + + Adds a new track to the animation using that property. + + .. note:: the type of the track is inferred based on the type of the property + + :param propertyName: The string that directs to the proper target (property name) + :type propertyName: string + + :return: A new animation track + :rtype: animation.track + + **Unique Property Names** + + * ``"call"`` - creates a function track + * ``"sound"`` - creates a sound track + * ``"clip"`` - creates an animation clip track + + .. helptext:: adds a new track to the animation + + .. lua:method:: [index] (propertyName) + + Adds a new track by passing the property name as index. + + .. helptext:: adds a new track to the animation + + .. lua:method:: removeTrack(trackObj) + + Removes this track + + :param trackObj: the track to be removed + :type trackObj: animation.track + + .. helptext:: removes track + + .. lua:method:: update(timeDelta) + + Updates the animation by ``time.delta`` + + :param timeDelta: time.delta + :type timeDelta: number + + .. helptext:: updates the animation + + .. lua:method:: play() + + Starts to play the animation + + .. helptext:: plays the animation + + .. lua:method:: pause() + + Pauses the animation + + .. helptext:: pauses the animation + + .. lua:method:: restart([shouldPlay = true]) + + Restarts the animation + + :param shouldPlay: Whether the animation should start playing + :type shouldPlay: boolean + + .. helptext:: restarts the animation + + .. lua:attribute:: playing: boolean + + Checks if the animation is playing + + .. helptext:: checks if the animation is playing + + .. lua:attribute:: tracks: table + + Gets the tracks of the animation + + .. helptext:: checks if the animation is playing + + .. lua:attribute:: duration: number + + Gets the duration of the animation + + .. helptext:: gets the duration of the animation + + .. lua:attribute:: time: number + + Gets/Sets the time elapsed through the animation + + .. helptext:: the elapsed time through the animation + + .. lua:attribute:: loopAmount: integer + + Sets the amount of times the animation loops. Set to 0 for an infinite loop. + + .. helptext:: the amount of times the animation loops + + .. lua:attribute:: onComplete: function + + Sets a function to call when the animation has been completed. + + .. helptext:: sets a function to call when the animation has been completed. + + .. lua:method:: group(animation1, ... , animationX) + + Groups multiple animations into one animations so they can be played synchronously using the same time. Each animation gets their own track (``type: animationClip``). At the front of the track (0 second), an animation clip key frame is placed with each animation as an animation clip. + + .. note:: Note that the duration of the grouped animation is the length of the longest animation. + + :param animation1: A single animation to be added to the group + :type animation1: animation + + :return: A new animation able to play all the animations synchronously + :rtype: animation + + .. helptext:: groups multiple animations to play synchronously + + .. lua:method:: sequence(animation1, ... , animationX) + + Groups multiple animations into a single animation so they can be played sequentially. + Each animation is placed in a singlar track one after another (``type: animationClip``). + + .. note:: Note that the duration of the sequenced animation is the sum of all the animations' duration. + + :param animation1: A single animation to be added to the sequence + :type animation1: animation + + :return: A new animation able to play all the animations sequentially + :rtype: animation + + .. helptext:: groups multiple animations to play in sequence + +Animation Track +############### + +.. lua:class:: animation.track + + .. code-block:: lua + :caption: How to create an animation.track + + ball = { x = 500, y = 400, col = color.red, image = asset.builtin.Planet_Cute.Character_Boy } + + ballColorAnimation = animation(ball) + + -- Animate the ball's color + colorTrack = ballColorAnimation.col + + -- Sets the key frames of the ball + colorTrack + :key(0.0) -- because the value was not inputted the first key's value is set to color.red because that is the current value of "col" + :key(1.0, color.blue, tween.hold) + :key(2.0, color.green) + + + firstKey = colorTrack:keyAtIndex(1) -- get the first key + firstKey.value = color.white + colorTrack:keyAtTime(1.0).value = color.black -- change the key value at time 1.0 from blue to magenta + colorTrack[2.0].value = color.magenta -- another way to get time + + ballSpriteAnimation = animation(ball) + + -- animate ball sprite with frames + spriteTrack = ballSpriteAnimation:property("image") -- another way to create a track for the "image" property + spriteTrack:frames({asset.builtin.Planet_Cute.Character_Boy, asset.builtin.Planet_Cute.Character_Cat_Girl, asset.builtin.Planet_Cute.Character_Horn_Girl}, { loop = 4, fps = 6 }) -- add frames to the track and make it loop 4 times at 6 fps + + groupAnimation = animation.group(ballColorAnimation, ballSpriteAnimation) + spriteAnimationTrack = groupAnimation.tracks[2] -- get the second track + secondTrackKey = spriteAnimationTrack:keyAtIndex(1) + local theDuration = secondTrackKey.duration -- get first key frame + secondTrackKey.duration = theDuration * 2 -- make the sprite animation loop 2 times + + groupAnimation:play() + + -- every frame + groupAnimation:update(time.delta) + + .. lua:attribute:: type: trackType + + Returns this track's type. + + * ``animation.track.boolean`` - boolean track + * ``animation.track.number`` - number track + * ``animation.track.vec2`` - vec2 track + * ``animation.track.vec3`` - vec3 track + * ``animation.track.vec4`` - vec4 track + * ``animation.track.color`` - color track + * ``animation.track.quat`` - quat track + * ``animation.track.sprite`` - sprite track + * ``animation.track.sound`` - sound track + * ``animation.track.function`` - function call track + * ``animation.track.animationClip`` - animationClip track: plays another animation + + .. helptext:: returns this track's type. + + .. lua:attribute:: target: table/userdata + + The table/userdata that contains that animated property + + .. helptext:: the table/userdata that contains that animated property + + .. lua:attribute:: property: string + + The string that directs to the proper target (property name) + + .. helptext:: the string that directs to the proper target + + .. lua:attribute:: duration: number + + The duration of the track + + .. helptext:: the duration of the track + + .. lua:attribute:: fps: integer + + The frames that are placed pre second + + .. helptext:: the frames that are placed pre second + + .. lua:attribute:: timeDelta: number + + The gap of time between each frame placed. + + .. helptext:: the gap of time between each frame placed. + + .. lua:method:: frames(theFrames[, frameProperties]) + + .. helptext:: quickly sets the frames of the track + .. lua:method:: frames() + + A way to quickly get/set the keyframes for a sprite track (``type = animation.track.sprite``). It uses the timeDelta as a way to space out the sprites. + + :param theFrames: a table of frames to represent the frames of the sprite animation + :type theFrames: table + + :param frameProperties: a table of properties of how the frames should behave + :type frameProperties: table + + * ``"delta"`` - sets the space of time each frame should be played. For example: 0.1 (this would space the frames every 0.1 seconds) + * ``"fps"`` - another way of doing delta but sets the fps of the sprites + * ``"loop"`` - number of times the sprites should loop + + .. helptext:: quickly gets the frames of the track + + .. lua:method:: adjustFrames() + + Adjusts the frames to fit the new timeDelta/fps. + + .. helptext:: adjusts the frames to fit the new timeDelta/fps + + .. lua:attribute:: count: integer + + The number of key frames in a track. + + .. helptext:: the number of key frames in a track + + .. lua:method:: key(time[, value, properties]) + + Add a key frame to the track. (supports chaining) + + :param time: The time of the key frame + :type time: number + :param value: The value of the key frame. Should be the same type as the track type. + :type value: any type + :param properties: Quick way to add properties of key + :type properties: table or easing enum + + .. note:: if value is nil then it will be set to current value of ``target[property]`` + + **Possible properties** + + `If easing enum` + + Sets the easing. Examples: ``tween.cubicIn`` or ``tween.hold`` + + `If table:` + + * ``"ease"`` - Sets the ease type of the key frame (``type: tween enum``) + * ``"strength"`` - Sets the strength of the easing (``type: number``) + * ``"loop"`` - Sets the amount of previous keys to be looped (``type: integer``) + + `If table but type of track is sound or animation clip` + + * ``"duration"`` - Sets the duration of the key frame (``type: number``) + * ``"start"`` - Sets the start time of the key frame (``type: number``) + + .. helptext:: adds a key to the track + + .. lua:method:: keyAtIndex(keyIndex) + + Returns the key frame at this index + + :param keyIndex: The index of the keyframe in the track keyframe list + :type keyIndex: integer + + :return: Key at that index + :rtype: animation.key + + .. helptext:: returns the key frame at this index + + .. lua:method:: keyAtTime(time) + + Returns the key frame at this time + + :param time: The time of the key frame + :type time: number + + :return: Key at that time + :rtype: animation.key + + .. helptext:: returns the key frame at this time + + .. lua:method:: [index] (time) + + Does the same thing as ``keyAtTime`` + + .. helptext:: returns the key frame at this time + + .. lua:method:: custom ([function]) + + Allows track to use a custom function to set the target + + :param function: Sets the custom function if no input then use default behavior + :type function: function + + .. code-block:: lua + :caption: How to use custom + + ani:target(boyEntity) + trac = ani.rz -- creates a track of the "rz" (rotation on z axis). + :key(0.0, nil) + :key(1.0, 720.0) + + trac:custom(function(value) -- because setting "rz" is unstable it is safer to set the rotation variable directly so we use a custom function + boy.rotation = quat.eulerAngles(0, 0, value) + end) + + .. helptext:: allows track to use a custom function to set the target + + .. lua:attribute:: openBeginning: boolean + + This is a variable that sets the 0 second key frame to be open. When true, the track will add a key frame at 0 second time and set the value to the current property value. + + .. note:: This can be used to smoothly go from gameplay to a cut scene without an abrupt cut. + + .. helptext:: makes the beginning of the animation open + + .. lua:attribute:: openEasing: animation.easing + + This is the easing of the open key frame + + .. helptext:: this is the easing of the open key frame + +Animation Key +############# + +.. lua:class:: animation.key + + .. lua:attribute:: time: number + + The time of the keyframe + + .. note:: this method might change the key frames index in the list + + .. helptext:: the time of the keyframe + + .. lua:attribute:: value: number + + The value of the keyframe + + .. helptext:: the value of the keyframe + + .. lua:attribute:: duration: number + + The duration of the keyframe for sound and animation clip key frames + + .. helptext:: the duration of the keyframe + + .. lua:attribute:: startTime: number + + The start time (offset) of sound and animation clip + + .. helptext:: the start time of the keyframe + + .. lua:attribute:: originalDuration: number + + Gets the original duration of sound or animation clip + + .. helptext:: gets the original duration of sound or animation clip + + .. lua:method:: delete() + + Deletes this key frame from its parent track list + + .. helptext:: deletes this key frame from its parent track list + + .. lua:attribute:: valid: boolean + + Checks if the keyframe is still valid + + .. helptext:: checks if the keyframe is still valid + + .. lua:attribute:: easing: animation.easing + + Gets the easing of this key + + .. helptext:: gets the easing of this key + +Animation Easing +################ + +.. lua:class:: animation.easing + + .. lua:attribute:: type: tween easing enum + + The type of easing of the key frame + + .. helptext:: gets the easing of this key + + .. lua:attribute:: strength: number + + Sets/gets the strength of the easing + + .. helptext:: the strength of the easing + + .. lua:attribute:: loopAmount: integer + + Sets/gets the amount of previous frames to loop + + .. helptext:: the amount of previous frames to loop + diff --git a/docs/source/api/entity.rst b/docs/source/api/entity.rst index 3615c34..623f5e7 100644 --- a/docs/source/api/entity.rst +++ b/docs/source/api/entity.rst @@ -60,9 +60,15 @@ entity .. literalinclude:: /code/Example_entity_destroy.codea/Main.lua :language: lua - + .. helptext:: mark this entity for destruction + .. lua:method:: destroyChildren() + + Destroys all the children of an entity + + .. helptext:: mark this entity's children for destruction + **Components** .. lua:method:: add(component, ...) @@ -563,9 +569,23 @@ entity .. lua:attribute:: destroyed: function Callback for the `destroyed()` event, which is called right before the entity is destroyed - + .. helptext:: callback invoked before this entity is destroyed + **Activation Callbacks** + + .. lua:attribute:: activated: function + + Callback for the ``activated()`` event, which is called when ``entity.active`` is set to true + + .. helptext:: callback invoked when this entity is activated + + .. lua:attribute:: deactivated: function + + Callback for the ``deactivated()`` event, which is called when ``entity.active`` is set to false + + .. helptext:: callback invoked when this entity is deactivated + **Physics Callbacks** .. lua:attribute:: collisionBegan2d: function @@ -608,6 +628,11 @@ entity .. lua:attribute:: hitTest: boolean [default = false] Enables hit testing for the ``touched(touch)`` event, which will filter touches based on collision checks using attached physics components on the main camera - + .. helptext:: enable hit testing for touch events + .. lua:attribute:: touchPriority: number [default = 0] + + Sets the priority of entity in ``touched(touch)`` event + + .. helptext:: set the priority of entity in touched diff --git a/docs/source/api/graphics.rst b/docs/source/api/graphics.rst index 9b0708a..e503f31 100644 --- a/docs/source/api/graphics.rst +++ b/docs/source/api/graphics.rst @@ -289,6 +289,26 @@ Text :return: The ``width`` and ``height`` of the text :rtype: number, number +.. lua:function:: textGlyphBounds(str, pos[, size]) + + .. helptext:: gets the bound of the glyph + + (Experimental subject to change) Gets the bound each characters in a text + + :param str: The text to query + :type str: string + :param pos: The position of the textbox + :type width: vec2 + :param size: The size of the textbox + :type width: vec2 + :return: The ``width`` and ``height`` of the text + :rtype: glyphBounds + + * ``x`` - x pos of glyph + * ``y`` - y pos of glyph + * ``width`` - width of glyph + * ``height`` - height of glyph + Gizmos ###### @@ -296,12 +316,125 @@ Gizmos are useful for drawing shapes in 2D/3D space for debugging and editing .. lua:module:: gizmos -.. lua:function:: line(x1, y1, z1, x2, y2, z2) +.. lua:function:: line(point1 , point2) Draws a 3D antialiased line + :param point1: First point of line + :type point1: vec3 + :param point2: Second point of line + :type point2: vec3 + .. helptext:: draw a line between two points +.. lua:function:: box(pos, size) + + Draws a 3D antialiased cube + + :param pos: Position of the box + :type pos: vec3 + :param size: Size of the box + :type size: vec3 + + .. helptext:: draws a gizmo box + +.. lua:function:: sphere(pos,[ radius = 1, segments = 32]) + + Draws a 3D antialiased sphere + + :param pos: Position of the sphere + :type pos: vec3 + :param radius: Radius of the sphere + :type radius: number + :param segments: Number of subdivisions that make up the sphere + :type segments: number + + .. helptext:: draws a gizmo sphere + +.. lua:function:: circlePlane(pos, normal,[ radius = 1, segments = 32, startAngle = 0, endAngle = 360]) + + Draws a 3D antialiased circle plane + + :param pos: Position of the circle + :type pos: vec3 + :param normal: Normal direction of the circle + :type normal: vec3 + :param radius: Radius of the circle + :type radius: number + :param segments: Number of subdivisions that make up the circle + :type segments: number + :param startAngle: Start degree of the circle + :type startAngle: number + :param endAngle: End degree of the circle + :type endAngle: number + + .. helptext:: draws a gizmo circle plane + +.. lua:function:: cylinder(pos,[ radius = 1, height = 1, segments = 32]) + + Draws a 3D antialiased cylinder + + :param pos: Position of the cylinder + :type pos: vec3 + :param radius: Radius of the cylinder + :type radius: number + :param height: Height of the cylinder + :type height: number + :param segments: Number of subdivisions that make up the cylinder + :type segments: number + + .. helptext:: draws a gizmo cylinder + +.. lua:function:: capsule(pos,[ radius = 1, height = 1, segments = 32]) + + Draws a 3D antialiased capsule + + :param pos: Position of the capsule + :type pos: vec3 + :param radius: Radius of the capsule + :type radius: number + :param height: Height of the capsule + :type height: number + :param segments: Number of subdivisions that make up the capsule + :type segments: number + + .. helptext:: draws a gizmo capsule + +.. lua:function:: polyline(points,[ closeShape = false]) + + Draws a 3D antialiased polyline + + :param points: Table of points (vec3) the represent the poly line + :type points: table + :param radius: Should the line be closed (polygon) + :type radius: boolean + + .. helptext:: draw a gizmo polyline with multiple points + +.. lua:function:: mesh(mesh) + + Draws a 3D antialiased mesh + + :param mesh: The mesh object to draw + :type mesh: mesh + + .. helptext:: draws a gizmo mesh + +.. lua:function:: icon(camera, iconSprite, pos, size) + + Draws a image in 3D shape facing the camera + + :param camera: The camera object + :type camera: camera + :param iconSprite: The image to be drawn + :type iconSprite: image + :param pos: The position of the image in 3D space + :type pos: vec3 + :param size: The size of the image in 3D space + :type size: number + + .. helptext:: draws a icon in world space facing camera + Color Space ########### diff --git a/docs/source/api/image.rst b/docs/source/api/image.rst index 38a7c52..91f59f6 100644 --- a/docs/source/api/image.rst +++ b/docs/source/api/image.rst @@ -183,6 +183,101 @@ Image .. helptext:: generate irradiance data into a target image + .. lua:method:: setPixel(xPos, yPos, pixelColor) + + Sets an inputed position to a new color + + :param xPos: The x position of the image + :type xPos: integer + :param yPos: The y position of the image + :type yPos: integer + :param pixelColor: The color to change the pixel to + :type pixelColor: color + + .. helptext:: sets an inputed position to a new color + + .. lua:method:: setValue(xPos, yPos, r, g, b, a) + + Same as set pixel but the inputted color value are from 0 to 1 + + :param xPos: The x position of the image + :type xPos: integer + :param yPos: The y position of the image + :type yPos: integer + + .. helptext:: sets an inputed position to a new color using value from 0 to 1 + + .. lua:method:: setForEach(loopingFunction) + + Loop over each pixel of the image and set its color value (0 to 1) + + :param loopingFunction: The function to loop over + :type loopingFunction: function + + .. code-block:: lua + :caption: How to set the pixels of an image + + img = image(255, 255) + + img:setForEach(function(x, y) + return math.random(), math.random(), math.random(), 1 + end) + + img:apply() + + .. helptext:: loops over every pixel of the image and output a color value + + .. lua:method:: apply() + + Applys all the colors that were set + + .. helptext:: applys all the colors that were set + + .. lua:method:: readback([immediately = true, includeMips = false]) + + Allows the user to get the image's color data + + :param immediately: Whether the image should allow reading immediately + :type immediately: boolean + :param includeMips: Whether the mip maps should be included + :type includeMips: boolean + + .. code-block:: lua + :caption: How to read the pixel values of an image + + -- img is a image + + img:readback() -- allows reading the pixels of the image + local pixelColor = color(img:getPixel(200, 200)) + + .. helptext:: allows the user to get the image's color data + + .. lua:method:: getPixel(xPos, yPos) + + Gets the color at the inputted position (0 to 255) + + :param xPos: The x position of the image + :type xPos: integer + :param yPos: The y position of the image + :type yPos: integer + :return: The colors at the inputted position (r, g, b, a) (0 to 255) + :rtype: number, number, number, number + + .. helptext:: gets the color at the inputted position + + .. lua:method:: getValue(xPos, yPos) + + Gets the color values at the inputted position (0 to 1) + + :param xPos: The x position of the image + :type xPos: integer + :param yPos: The y position of the image + :type yPos: integer + :return: The color values at the inputted position (r, g, b, a) (0 to 1) + :rtype: number, number, number, number + + .. helptext:: gets the color values at the inputted position + Image Formats ------------- diff --git a/docs/source/api/input.rst b/docs/source/api/input.rst index fa5cc32..0eec9ed 100644 --- a/docs/source/api/input.rst +++ b/docs/source/api/input.rst @@ -145,9 +145,19 @@ Touches .. lua:attribute:: precisePrevPos: vec2 The previous precise location of the touch (if available) - + .. helptext:: get the precise previous position of this touch + + .. lua:function:: cancelTouch(scene) + + Cancels the touch of a scene + + :param scene: The scene to cancel touch to + :type scene: scene + + .. helptext:: cancels the touch in a scene + Gestures ######## @@ -212,14 +222,50 @@ Gestures .. lua:attribute:: touchCount: integer The current number of touches associated with this gesture - + .. helptext:: get the touch count for this gesture + .. lua:attribute:: direction: enum + + The direction of the swipe + + .. helptext:: get the direction of the swipe + + .. lua:attribute:: left: integer + + Left direction enum + + .. helptext:: left direction enum + + .. lua:attribute:: right: integer + + Right direction enum + + .. helptext:: right direction enum + + .. lua:attribute:: up: integer + + Up direction enum + + .. helptext:: up direction enum + + .. lua:attribute:: down: integer + + Down direction enum + + .. helptext:: down direction enum + + .. lua:attribute:: all: integer + + All direction enum + + .. helptext:: all direction enum + .. lua:class:: gesture.tap Tap gesture recognizer (using system gesture recognizer for implementation) - .. lua:staticmethod:: gesture.tap(callback[, minTouches = 1, maxTouches = 1]) + .. lua:staticmethod:: gesture.tap(callback[, tapCount = 1, touchCount = 1]) Creates and registers a new tap gesture recognizer that will call ``callback(gesture)`` when recognized @@ -235,7 +281,7 @@ Gestures Pan gesture recognizer (using system gesture recognizer for implementation) - .. lua:staticmethod:: gesture.pan(callback[, minTouches = 1, maxTouches = 1]) + .. lua:staticmethod:: gesture.pan(callback[, minTouches = 1, maxTouches = 1, trackpadSupport = false]) Creates and registers a new pan gesture recognizer that will call ``callback(gesture)`` when recognized @@ -278,9 +324,43 @@ Gestures .. lua:attribute:: enabled: boolean Enables/disables this gesture recognizer + + .. helptext:: whether the gesture recognizer is enabled +.. lua:class:: gesture.swipe + + Swipe gesture recognizer (using system gesture recognizer for implementation) + + .. lua:staticmethod:: gesture.swipe(callback[, swipeDirection = gesture.all, touchCount = 1]) + + Creates and registers a new swipe gesture recognizer that will call ``callback(gesture)`` when recognized + + :return: The gestures in this order (left, right, up, down). But if a direction is not included, it is ignored. + :rtype: gesture.swipe, gesture.swipe, gesture.swipe, gesture.swipe + + .. helptext:: create a swipe gesture recognizer + + .. lua:attribute:: enabled: boolean + + Enables/disables this gesture recognizer + .. helptext:: whether the gesture recognizer is enabled +.. lua:class:: gesture.longPress + + Rotation gesture recognizer (using system gesture recognizer for implementation) + + .. lua:staticmethod:: gesture.longPress(callback[, tapCount = 0, touchCount = 1, allowableMovement = 10, minimumPressDuration = 0.5]) + + Creates and registers a new long press gesture recognizer that will call ``callback(gesture)`` when recognized + + .. helptext:: create a long press gesture recognizer + + .. lua:attribute:: enabled: boolean + + Enables/disables this gesture recognizer + + .. helptext:: get or set if the gesture recognizer is enabled Keyboard ######## @@ -827,5 +907,186 @@ Gamepad .. helptext:: get if the directional pad is moved up .. lua:attribute:: down: boolean - + .. helptext:: get if the directional pad is moved down + +Mouse +######## + +.. lua:currentmodule:: None + +.. lua:class:: mouse + + .. lua:attribute:: active: boolean + + Checks if a mouse is currently active. + + .. helptext:: checks if a mouse is active + + .. lua:attribute:: connected: function(mouse) + + Callback for when a mouse is connected + + .. helptext:: callback to call when a mouse is connected + + .. lua:attribute:: disconnected: function(mouse) + + Callback for when a mouse is disconnected + + .. helptext:: callback to call when a mouse is disconnected + + .. lua:attribute:: left: mouse.button + + .. helptext:: gets the left mouse button + + .. lua:attribute:: middle: mouse.button + + .. helptext:: gets the middle mouse button + + .. lua:attribute:: right: mouse.button + + .. helptext:: gets the right mouse button + + .. lua:attribute:: scroll: vec2 + + .. helptext:: gets the mouse scoll value + + .. lua:attribute:: x: number + + .. helptext:: gets the x position of the mouse + + .. lua:attribute:: y: number + + .. helptext:: gets the y position of the mouse + + .. lua:attribute:: pos: vec2 + + Return a vec2 of both the x and y position + + .. helptext:: gets the position of the mouse + + .. lua:attribute:: dx: number + + .. helptext:: gets the delta X of the mouse + + .. lua:attribute:: dy: number + + .. helptext:: gets the delta Y of the mouse + + .. lua:attribute:: deltaX: number + + .. helptext:: gets the delta X of the mouse + + .. lua:attribute:: deltaY: number + + .. helptext:: gets the delta Y of the mouse + + .. lua:attribute:: delta: vec2 + + Return a vec2 of both dx and dy + + .. helptext:: gets the delta of the mouse + + .. lua:attribute:: visible: boolean + + Sets whether the mouse is visible or hidden + + .. helptext:: set the visibility of the mouse + + .. lua:class:: button + + .. lua:attribute:: pressing: boolean + + .. helptext:: get whether this button is being pressed + + .. lua:attribute:: pressed: + + .. helptext:: get whether this button was just pressed + + .. lua:attribute:: released: boolean + + .. helptext:: get whether this button was just released + + .. lua:attribute:: value: number + + .. helptext:: get the analog value of this button + + .. lua:attribute:: touching: boolean + + .. helptext:: get whether the touchpad is being touched + +.. lua:module:: mouse + +.. lua:function:: default() + + Changes the mouse back to its default style + + .. helptext:: sets the mouse style to default + +.. lua:function:: path(polygon1, polygon...) + + Turns the mouse style to a path (allows multiple polygons for unique shapes) + + :param polygon1: Table that represents point of the mouse shape (offset from the mouse) + :type polygon1: table + :param polygon...: for more polygons + :type polygon...: table + + .. helptext:: sets the mouse style to a path + +.. lua:function:: rect(pos, size [, roundedRadius = 0]) + + Turns the mouse style to a rectangle + + :param pos: Represents the positions of the rectangle from the mouse + :type pos: vec2 + :param size: Represents the size of the rectangle + :type size: vec2 + :param roundedRadius: Radius of the rectangle + :type roundedRadius: number + + .. helptext:: sets the mouse style to roundable rectangle + +.. lua:currentmodule:: None + +**Global Mouse Funcitons** + +.. lua:function:: mousePressed(mouseName) + + Function for when the mouse is pressed + + :param mouseName: return the name of the mouse being selected ("left", "right", "middle") + :type mouseName: string + + .. helptext:: function that is called when the mouse has been pressed + +.. lua:function:: mouseReleased(mouseName) + + Function for when the mouse is released + + :param mouseName: return the name of the mouse being selected ("left", "right", "middle") + :type mouseName: string + + .. helptext:: function that is called when the mouse has been released + +.. lua:function:: mouseChanged(mouseName, changeState) + + Function for when the mouse has been changed + + :param mouseName: Returns the name of the mouse being selected ("left", "right", "middle") + :type mouseName: string + :param changeState: Inputs true if the mouse was pressed or false if the mouse was released + :type wasPressed: boolean + + .. helptext:: function that is called when the mouse has been changed + +.. lua:function:: mouseMoved(deltaX, deltaY) + + Function for when the mouse has been moved + + :param deltaX: The delta x of the mouse + :type deltaX: number + :param deltaY: The delta y of the mouse + :type deltaY: number + + .. helptext:: function that is called when the mouse has been moved diff --git a/docs/source/api/math_types.rst b/docs/source/api/math_types.rst index bd638f6..3e3d791 100644 --- a/docs/source/api/math_types.rst +++ b/docs/source/api/math_types.rst @@ -714,3 +714,173 @@ Axis-Aligned Bounding Box (AABB) .. lua:module:: bounds .. lua:class:: aabb + + .. lua:attribute:: min: vec3 + + .. helptext:: minimum position of the bound + + .. lua:attribute:: max: vec3 + + .. helptext:: maximum position of the bound + + .. lua:attribute:: size: vec3 + + Size of the bounding box + + .. helptext:: size of the bound + + .. lua:attribute:: offect: vec3 + + Offset of the bounding box + + .. helptext:: offset of the bound + + .. lua:attribute:: valid: boolean + + Checks if the bounding box is valid + + .. helptext:: checks if the bound is valid + + .. lua:method:: set(min, max) + + :param min: The minimum position of the bounding box + :type min: vec3 + :param max: The maximum position of the bounding box + :type max: vec3 + + .. helptext:: sets the new min and max of the bound + + .. lua:method:: translate(amount) + + :param amount: The amount to move the bounding box + :type amount: vec3 + + .. helptext:: translates the bounding box + + .. lua:method:: transform(transformMatrix) + + :param transformMatrix: The matrix used to transform the current matrix + :type transformMatrix: mat4 + :return: New bounds to fit the transformed bound + :rtype: aabb + + .. helptext:: creates news bound to fix the transformed bound + + .. lua:method:: encapsulate(point) + + Adjust the bound to fit a point + + :param point: The point you want to fit + :type point: vec3 + + .. helptext:: adjust the bound to fit a point + + .. lua:method:: encapsulate(otherAABB) + + Adjust the bound to fit another bound + + :param otherAABB: The aabb you want to fit + :type otherAABB: aabb + + .. helptext:: adjust the bound to fit another bound + + .. lua:method:: raycast(origin, dir) + + :param origin: The position of the ray + :type origin: vec3 + :param dir: The direction of the ray + :type dir: mat4 + :return: The hit infomation of the raycast + :rtype: hit + + .. helptext:: performs a raycast on the bound box + +.. lua:class:: hit + + .. lua:attribute:: point: vec3 + + The position where the raycast hit + + .. helptext:: the position where the raycast hit + + .. lua:attribute:: normal: vec3 + + The normal of the point hit + + .. helptext:: the normal of the point hit + +Math Extensions +############### + +.. lua:currentmodule:: None + +.. lua:class:: math + + The following are extensions to the Lua math class. + + .. lua:method:: lerp(a, b, t) + + Interpolate a and b by the a given factor (typically between 0 and 1) + + :param a: The first point + :type a: number + :param b: The second point + :type b: number + :param t: Value between 0 and 1 to represent the progress between a and b + :type t: number + :return: The interpolated value between a and b at ratio t. + :rtype: number + + .. helptext:: interpolate two numbers by a t value + + .. lua:method:: inverseLerp(a, b, v) + + Returns the ratio from a to b where the interpolated value is v. + + :param a: The first point + :type a: number + :param b: The second point + :type b: number + :param v: Value between a and b + :type v: number + :return: The ratio from a to b at which the interpolated value is v + :rtype: number + + .. helptext:: the ratio from two number where the interpolated value is v + + .. lua:method:: sign(value) + + Returns -1 if value < 0, 0 if value == 0, 1 if value > 0. + + :param value: The value to take the sign of + :type value: number + :return: The sign of the value + :rtype: number + + .. helptext:: returns -1 if value < 0, 0 if value == 0, 1 if value > 0 + + .. lua:method:: clamp(value, a, b) + + Clamp the value between `a` and `b`. If the value is less than `a`, the function outputs `a`. If the value is greater than `b`, the function outputs `b`. Returns value otherwise. + + :param value: The value to clamp + :type value: number + :param a: The left end of the clamp + :type a: number + :param b: The right end of the clamp + :type b: number + :return: The t (progress) that v is between a and b + :rtype: number + + .. helptext:: clamp the value between a and b + + .. lua:method:: clamp01(value) + + Clamp the value between 0 and 1. + + :param value: The value to clamp + :type value: number + :return: The clamped value + :rtype: number + + .. helptext:: clamp the value between 0 and 1 \ No newline at end of file diff --git a/docs/source/api/physics2d.rst b/docs/source/api/physics2d.rst index 23b7d8c..a78732d 100644 --- a/docs/source/api/physics2d.rst +++ b/docs/source/api/physics2d.rst @@ -468,9 +468,33 @@ Collision .. lua:attribute:: body: physics2d.body The body this collider belongs to - + .. helptext:: get the body this collider belongs to + .. lua:method:: collide(otherCollider) + + Checks the collision between this collider and another collider, and returns information about the collision. + + :param otherCollider: The other collider to collide with + :type otherCollider: collider + + :return: ``didCollide[, point, normal, penetration]`` - `didCollide` is whether the collision happened + :rtype: boolean[, vec2, vec2, number] + + .. helptext:: check for a collision with another collider + + .. lua:method:: overlap(otherCollider) + + Checks if the collider overlaps with another collider. + + :param otherCollider: The other collider to overlap with + :type otherCollider: collider + + :return: Checks whether the two colliders are overlapping + :rtype: boolean + + .. helptext:: check for an overlap with another collider + .. lua:class:: circle: collider .. lua:attribute:: radius: number @@ -581,9 +605,21 @@ Collision .. lua:attribute:: otherCollider: physics2d.collider The second collider involved in this collision contact - + .. helptext:: get the other collider in the contact + .. lua:attribute:: entity: entity + + The first entity in this contact (the entity receiving the callback) + + .. helptext:: get the entity in the contact + + .. lua:attribute:: otherEntity: entity + + The second entity involved in this collision contact + + .. helptext:: get the other entity in the contact + .. lua:class:: rayHit .. lua:attribute:: point: vec2 @@ -864,4 +900,35 @@ Constraints .. lua:class:: motor: joint - *Not implemented yet* \ No newline at end of file + *Not implemented yet* + +Settings +######## + +.. lua:class:: settings + + .. lua:attribute:: debugDraw: boolean + + Draws physics objects in the scene. + + .. helptext:: draws physics objects in the scene + + .. lua:attribute:: gravity: vec2 + + Changes the gravity of the physics world. + + .. helptext:: gravity of the physics world + + .. lua:attribute:: velocityIterations: number + + .. helptext:: velocity iterations + + .. lua:attribute:: positionIterations: number + + .. helptext:: position iterations + + .. lua:attribute:: paused: boolean + + Get or set whether the physics simulation is currently paused. + + .. helptext:: pauses the physics simluation \ No newline at end of file diff --git a/docs/source/api/physics3d.rst b/docs/source/api/physics3d.rst index cf3857d..14b0481 100644 --- a/docs/source/api/physics3d.rst +++ b/docs/source/api/physics3d.rst @@ -505,6 +505,29 @@ physics3d .. lua:attribute:: body: physics3d.body - The body of the collider that was hit by the ray - + The body of the collider which was hit by the ray. + .. helptext:: get the raycast hit body + +Settings +######## + +.. lua:class:: settings + + .. lua:attribute:: debugDraw: boolean + + Draws physics objects in the scene. + + .. helptext:: draws physics objects in the scene + + .. lua:attribute:: gravity: vec3 + + Changes the gravity of the physics world. + + .. helptext:: gravity of the physics world + + .. lua:attribute:: paused: boolean + + Get or set whether the physics simulation is paused. + + .. helptext:: pauses the physics world \ No newline at end of file diff --git a/docs/source/api/scene.rst b/docs/source/api/scene.rst index f8a48cf..28e146b 100644 --- a/docs/source/api/scene.rst +++ b/docs/source/api/scene.rst @@ -60,9 +60,27 @@ scene .. lua:attribute:: world3d: physics3d.world Gets the scene's 3D physics world, providing access to various physics functions and properties such as :lua:meth:`physics3d.world.applyForce` - + .. helptext:: 3D physics world of the scene + .. lua:attribute:: physics2d: physics2d.settings + + Gets the scene's 2D physics settings, providing access to various physics functions and properties such as :lua:meth:`physics2d.settings.debugDraw` + + .. helptext:: 2D physics settings of the scene + + .. lua:attribute:: physics3d: physics3d.settings + + Gets the scene's 3D physics settings, providing access to various physics functions and properties such as :lua:meth:`physics3d.settings.debugDraw` + + .. helptext:: 2D physics settings of the scene + + .. lua:attribute:: time: time.settings + + Gets the scene's time settings, providing access to various time functions and properties such as :lua:meth:`time.settings.autoUpdate` + + .. helptext:: time settings of the scene + .. lua:attribute:: sky Sets the sky visuals, which will depend on the type used: @@ -126,14 +144,55 @@ scene :rtype: entity - .. lua:method:: entities([activeOnly = true]) + .. lua:method:: entities([includeFlag = scene.DEFAULT]) + + Returns a table containing entities in the scene + + :param includeFlag: Flag to include certain entities. + :rtype: table - Returns a table containing all root entities + * ``scene.DEFAULT`` - only active entities *not including the children* + * ``scene.INACTIVE`` - include inactive entities + * ``scene.CHILDREN`` - include all the children and sub childrens of the entities + * ``scene.ALL`` - include all entities in the scene: ``scene.INACTIVE | scene.CHILDREN`` + .. code-block:: lua + :caption: Getting all the entities + + scen = scene.default2d("test") + + enti = scen:entity("enti") + childEnti = enti:child("childEnti") + + otherEnti = scen:entity("otherEnti") + otherEnti.active = false + + -- include only enti (you could input scene.DEFAULT in parameter for same result) + entityList1 = scen:entities() + + -- include only enti and childEnti + entityList2 = scen:entities(scene.CHILDREN) + + -- include only enti and otherEnti (no children included) + entityList2 = scen:entities(scene.INACTIVE) + + -- loop over all entities in the scene (can use scene.ALL instead) + scen:forEach(function(currentEnti) + print(currentEnti.name) + end, scene.INACTIVE | scene.CHILDREN) + .. helptext:: get the root entities in the scene - :param activeOnly: When set, returns only active root entities - :rtype: table + + .. lua:method:: forEach(loopFunction, [includeFlag = scene.DEFAULT]) + + Call a function `loopFunction` for each matching entity in the scene. + + :param loopFunction: Function to loop over + :type loopFunction: function(entity) + :param includeFlag: Flag to include certain entities. + + .. helptext:: loops over entities in the scene using a function .. lua:method:: index(name) [metamethod] diff --git a/docs/source/api/sound.rst b/docs/source/api/sound.rst index c0654ff..b96749a 100644 --- a/docs/source/api/sound.rst +++ b/docs/source/api/sound.rst @@ -135,6 +135,12 @@ The sound module provides a way to play and manage sound effects and background Gets the length of this sound source (in seconds) + .. helptext:: gets the length of this sound source (in seconds) + + .. lua:attribute:: key: assetKey + + The asset key for this sound (if it has one) + .. helptext:: length of the sound in seconds .. lua:class:: instance @@ -170,9 +176,33 @@ The sound module provides a way to play and manage sound effects and background .. lua:attribute:: time: number Get/set the current time of the sound instances play head (in seconds) - + .. helptext:: current playback time + .. lua:attribute:: samplerate: number + + Get the sample rate of the sound instance. + + .. helptext:: current playback samplerate + + .. lua:attribute:: amplitude: number + + Get the amplitude of the sound instance at the current time + + .. helptext:: current playback amplitude + + .. lua:attribute:: wave: table + + Get the wave data of the sound instance at the current time + + .. helptext:: current playback wave data + + .. lua:attribute:: fft: table + + Get the fft data of the sound instance at the current time + + .. helptext:: current playback fft data + .. lua:method:: stop Stop the sound instance from playing diff --git a/docs/source/api/style.rst b/docs/source/api/style.rst index 3f121b6..6917a82 100644 --- a/docs/source/api/style.rst +++ b/docs/source/api/style.rst @@ -601,6 +601,12 @@ Used by drawing commands and shaders to control stencil operations Text Style ########## +.. lua:function:: font(assetKey) + + Adds a custom font in Codea using it's asset key + + .. helptext:: adds a custom font in Codea using it's asset key + .. lua:function:: fontSize(size) .. helptext:: set the font size for text() diff --git a/docs/source/api/tilemap.rst b/docs/source/api/tilemap.rst new file mode 100644 index 0000000..f706259 --- /dev/null +++ b/docs/source/api/tilemap.rst @@ -0,0 +1,532 @@ +tilemap +======= + +API for creating tile maps + +Content +####### + + - ``tm.tiles`` - information on a single tile + - ``tm.ruleset`` - information on how sprites should behavior in a tile + - ``tm.tileset`` - collection of tiles used in the scene + - ``tm.layer`` - the placement of tiles in the single layer + - ``tm.tilemap`` - the grouping of tilemap layers to draw to the scene + +.. lua:module:: tm + +Tile +#### + +.. lua:class:: tile + + .. code-block:: lua + :caption: How to use tile + + myTileset = tm.tileset() + + newTile = myTileset:tile() + + newTile:sprite(asset.dirtTile):group(7):collision(tm.collision.square) + :ruleset(myRuleSet) + + spriteImg = newTile:sprite() + theRuleset = newTile:ruleset() + + .. lua:attribute:: id: number + + .. helptext:: the tile's identifier + + .. lua:method:: sprite(spriteIcon) + + .. helptext:: sets the sprite of the rule + .. lua:method:: sprite() + + Sets/gets the sprite image of the tile + + :param spriteIcon: The image that the tile contains + :type spriteIcon: sprite + + No parameter: + + :return: The sprite image + :rtype: sprite + + .. helptext:: gets the sprite of the tile + + .. lua:method:: group(groupNum) + + Sets the group of the tile + + :param groupNum: The group number the tile is from + :type groupNum: number + + :return: self for function chaining + :rtype: tile + + .. helptext:: sets the group of the tile + + .. lua:method:: collision(mode) + + Sets the collision mode of the tile + + :param mode: The enum of the collision + :type mode: enum + + :return: self for function chaining + :rtype: tile + + **Collision Mode Enum:** + + * ``tm.collision.none`` - no collision + * ``tm.collision.square`` - for square collision + * ``tm.collision.sprite`` - for sprite collision + + .. helptext:: sets the collision mode of the tile + + .. lua:method:: ruleset(theRuleset) + + .. helptext:: sets the ruleset of the tile + .. lua:method:: ruleset() + + Sets/gets the ruleset of the tile + + :param theRuleset: The ruleset to be applied to the tile + :type theRuleset: tm.ruleset + + No parameter: + + :return: The ruleset of the tile + :rtype: tm.ruleset + + .. helptext:: gets the ruleset of the tile + +Ruleset +####### + +.. lua:class:: ruleset + + A ruleset is an object to determine how the same tiles should arrange using certain rules. + + .. lua:method:: rule() + + Creates a rule in the ruleset and selects it. Following ruleset functions will apply to this rule. + + :return: self for function chaining. + :rtype: ruleset + + .. helptext:: creates a rule in the ruleset + + .. lua:method:: [index] (ruleNum) + + Select the rule in the ruleset. Following ruleset functions will apply to this rule. + + :param ruleNum: the index of the rule in the ruleset + :type ruleNum: integer + + :return: self for function chaining + :rtype: ruleset + + .. helptext:: creates a rule in the ruleset + + **Below happens to rule created above** + + .. lua:method:: sprite(spriteIcon) + + .. helptext:: sets the sprite image of the rule + + .. lua:method:: sprite() + + Sets/gets the sprite image of the rule + + :param spriteIcon: The image that the rule contains + :type spriteIcon: sprite + + No parameter: + + :return: One sprite image for regular and a table for `random` + :rtype: sprite or table + + .. helptext:: gets the sprite image of the rule + + .. lua:method:: random(spriteList) + + Sets the sprites that will be randomly selected + + :param spriteList: The images that the rule contains + :type spriteList: table + + :return: self for function chaining + :rtype: ruleset + + .. helptext:: sets the sprites that will be randomly selected + + .. lua:method:: area(row1,... , rowX) + + Sets the tile area rule to determine which sprite should be displayed in the correct spot. + + .. note:: The rows must be an odd number from 3 to 7. Rows and columns should be the same length + + :param rowX: The layout of the tile (sprite) with other tiles + :type spriteList: string + + * ``@`` - center tile + * ` ` - ignore tile (empty space) + * ``=`` - this tile + * ``x`` - not this tile + * ``g`` - tiles of the same group + + .. code-block:: lua + :caption: How to use area + + local wallRules = tm.ruleset() + + wallRules:rule():sprite(setImgAtlas.c4r2) + :area(" = ", + "=@x", + " = ") + + + :return: self for function chaining + :rtype: ruleset + + .. helptext:: sets the tile area rule to determine which sprite should be displayed + + .. lua:method:: rotate(shouldRotate) + + .. helptext:: sets the rotation of the rule's tile + + .. lua:method:: rotate() + + Rotates the rule's tile + + :param shouldRotate: Whether the sprite should be rotated + :type shouldRotate: boolean + + :return: self for function chaining + :rtype: ruleset + + .. helptext:: gets the rotation of the rule's tile + + .. lua:method:: flip(flipX, flipY) + + .. helptext:: sets the flip of the rule + + .. lua:method:: flip() + + Flips the rule's tile + + :param flipX: flip sprite horizontally + :type flipX: boolean + :param flipY: flip sprite vertically + :type flipY: boolean + + :return: self for function chaining + :rtype: ruleset + + .. helptext:: gets the flip of the rule + + .. lua:method:: collision(mode) + + Sets the collision mode of the rule's tile + + :param mode: The enum of the collision + :type mode: enum + + :return: self for function chaining + :rtype: tile + + .. helptext:: sets the collision mode of the rule's tile + + .. lua:method:: delete() + + Deletes the currently selected rule from the ruleset + + :return: self for function chaining + :rtype: tile + + .. helptext:: deletes the currently selected rule from the ruleset + + .. lua:method:: clear() + + Clears all rules from the ruleset + + :return: self for function chaining + :rtype: tile + + .. helptext:: clears the ruleset + + .. lua:attribute:: count: number + + Gets the number of rules in ruleset + + .. helptext:: the amount of rules + +Tileset +####### + +.. lua:class:: tileset + + .. code-block:: lua + :caption: How to created tileset + + myTileset = tm.tileset() + + newTile = myTileset:tile("dirt") + newTile2 = myTileset["dirt"] -- get the tile from the tileset by name + newTile3 = myTileset[newTile.id] -- get the tile from the tileset by its id + + .. lua:method:: tile(tileName) + + Creates a tile in the tileset + + :param tileName: Name of the tile in the tileset + :type tileName: string + + :return: The newly created tile + :rtype: tile + + .. helptext:: create a tile in the tileset + + .. lua:method:: [index] (tileId) + + Selects a tile from tileset using its id + + :param tileId: The id of the tile. + :type tileId: integer + + :return: Selected tile + :rtype: tile + + .. helptext:: selects a tile from tileset using its id + + .. lua:method:: [index] (tileName) + + Select tile from tileset using its name + + :param tileName: The name of the tile. + :type tileName: string + + :return: Selected tile + :rtype: tile + + .. helptext:: selects a tile from tileset using its name + + .. lua:method:: clear() + + Clears all tiles from the tileset + + :return: self for function chaining + :rtype: tile + + .. helptext:: clears the tileset + + .. lua:attribute:: count: number + + Gets the number of rules in ruleset + + .. helptext:: the amount of tiles in the tileset + +Tilemap +####### + +.. lua:class:: tilemap + + .. code-block:: lua + :caption: How to create a tilemap + + myTileset = tm.tileset() + + myTilemap = tm.tilemap(myTileset) + + .. lua:method:: layer(layerName) + + Creates a layer in the tilemap + + :param layerName: Name of the layer in this tilemap + :type layerName: string + + :return: The newly created layer + :rtype: layer + + .. helptext:: creates a layer in the tilemap + + .. lua:method:: [index] (layerName) + + Gets a layer from tilemap using its name + + :param layerName: The name of the layer + :type layerName: string + + :return: Selected layer + :rtype: layer + + .. helptext:: gets a layer from tilemap using its name + + .. lua:method:: draw() + + Draws all the layers of the tilemap + + .. helptext:: draws all the layers of the tilemap + + .. lua:attribute:: world2d: world2d + + Gets/sets the physics world. + + .. helptext:: gets/sets the physics world. + + .. lua:attribute:: tileset: tileset + + Gets/sets the tileset. + + .. helptext:: Gets/sets the physics world. + +Layer +##### + +.. lua:class:: layer + + .. code-block:: lua + :caption: How to create a layer + + myTileset = tm.tileset() + + myTilemap = tm.tilemap(myTileset) + + layer1 = myTilemap:layer("layer1") + + .. lua:attribute:: id: number + + .. helptext:: the layer's identifier + + .. lua:attribute:: name: string + + .. helptext:: the layer's name + + .. lua:attribute:: offset: vec3 + + Adjusts the position of tilemap + + .. helptext:: adjusts the position of tilemap + + .. lua:method:: origin() + + Position of bottom left tile + + :return: The x, y, and z of the origin + :rtype: number, number, number + + .. helptext:: position of bottom left tile + + .. lua:method:: size() + + Size of the tilemap + + :return: The x, y, and z of the size + :rtype: number, number, number + + .. helptext:: size of the tilemap + + .. lua:method:: clear() + + Clears all tiles from the layer + + .. helptext:: clears the layer + + .. lua:method:: get(xPos, yPos) + + Gets the tileID at this position + + :param xPos: The x position of the tile + :type xPos: number (integer) + :param yPos: The y position of the tile + :type yPos: number (integer) + + :return: The tileId at that position along with it's tileset + :rtype: number, tileset + + .. note:: If tile position does not exist then returns 0 + + .. helptext:: gets the tile id at this position + + .. lua:method:: set(xPos, yPos, tileID|theTile) + + Sets the tile at this position + + :param xPos: The x position of the tile + :type xPos: number (integer) + :param yPos: The y position of the tile + :type yPos: number (integer) + :param tileID|theTile: Can take in a tileID or the tile itself + :type tileID|theTile: number | tile + + .. helptext:: gets the tile id at this position + + .. lua:method:: draw() + + Draws this layer + + .. helptext:: draws this layer + + .. lua:method:: fill(xPos, yPos, tileID|theTile) + + Fills the tilemap with this tile + + :param tileID|theTile: Can take in a tileID or the tile itself + :type tileID|theTile: number | tile + + .. helptext:: fills the tilemap with this tile + + .. lua:method:: resize(xSize, ySize) + + Resizes the layer to a new size + + :param xSize: The new width of the layer + :type xSize: number + :param ySize: The new height of the layer + :type ySize: number + + .. helptext:: resizes the layer to the new size + + .. lua:method:: visit(callback) + + Iterates through all the positions of the the layers and calls this function. The callback function's input takes x, y, z, and tileID (the tile at that position) + + :param callback: The function that will be call each position: function(x, y, z, tileID, tileset) + :type callback: function(number, number, number, number, tileset) + + .. helptext:: iterates over all the positions of the the layers + + .. lua:method:: worldToTile(xPos, yPos) + + Gets the tile position from the world's position + + :param xPos: The x position of the world + :type xPos: number (integer) + :param yPos: The y position of the world + :type yPos: number (integer) + + :return: returns the tile position from world space + :rtype: number, number + + .. helptext:: gets the tile position from the world's position + + .. lua:method:: tileToWorld(xPos, yPos) + + Gets the world position from the tiles's position + + :param xPos: The x position of the tile in layer + :type xPos: number (integer) + :param yPos: The y position of the tile in layer + :type yPos: number (integer) + + :return: returns the world position from tile space + :rtype: number, number + + .. helptext:: gets the world position from the tiles's position + + .. lua:method:: bounds() + + :return: returns bounds of the layer + :rtype: bounds.aabb + + .. helptext:: the bound of the layer \ No newline at end of file diff --git a/docs/source/api/time.rst b/docs/source/api/time.rst new file mode 100644 index 0000000..4c0afcb --- /dev/null +++ b/docs/source/api/time.rst @@ -0,0 +1,69 @@ +time +===== + +.. lua:class:: time + + .. lua:attribute:: delta: number + + The time between the last frame and this frame + + .. helptext:: the time between the last frame and this frame + + .. lua:attribute:: unscaledDelta: number + + Time delta without being affected by the time scale + + .. helptext:: time delta without being affected by the time scale + + .. lua:attribute:: fixedDelta: number + + Sets the time delta of the program (like setting the fps) + + .. helptext:: sets the time delta of the program (like setting the fps) + + .. lua:attribute:: elapsed: number + + The time that has past since the program started + + .. helptext:: the time that has past since the program started + + .. lua:attribute:: unscaledElapsed: number + + The time that has past without being affected by the time scale + + .. helptext:: the time that has past without being affected by the time scale + + .. lua:attribute:: scale: number + + Sets/gets the scaling of time to speed up or slow down (default is 1) + + .. helptext:: the scaling of time + +Settings +######## + +For the scene time properties + +.. lua:class:: time.settings + + .. lua:attribute:: autoUpdate: boolean + + Set to false prevents the scene from updating, draw, touching automatically (for manual use) + + .. helptext:: sets if the scene should auto update + + .. lua:attribute:: maximumTimeStep: number + + .. helptext:: the maximum Time Step + + .. lua:attribute:: fixedDelta: number + + Sets the time delta of the scene (like setting the fps) + + .. helptext:: sets the time delta of the scene (like setting the fps) + + .. lua:attribute:: scale: number + + Sets the scaling of time to speed up or slow down (default is 1) + + .. helptext:: sets the scaling of time to speed up or slow down \ No newline at end of file diff --git a/docs/source/api/tween.rst b/docs/source/api/tween.rst index 406e307..a9fc3f9 100644 --- a/docs/source/api/tween.rst +++ b/docs/source/api/tween.rst @@ -79,9 +79,27 @@ Procedurally animate values over time, otherwise known as tweening :param easeType: The easing function to use :type easeType: constant + + .. helptext:: set the easing function for the current tween segment + + .. lua:method:: ease(easeFunction) + Sets a custom easing callback for the current tweening segment (created via ``to{}``) + + :param easeCallback: The easing callback to use + :type easeCallback: function(t, from, to) + .. helptext:: set the easing function for the current tween segment + .. lua:method:: delay(time) + + Adds a delay to the tween for a certain time + + :param time: Time in seconds to delay the tween + :type easeType: integer + + .. helptext:: adds a deley to the tween + .. lua:method:: loop(count) Sets the loop count for the current tweening segment (created via ``to{}``). Using `nil` for the count will result in an infinite number of loops @@ -149,9 +167,18 @@ Procedurally animate values over time, otherwise known as tweening :param callback: The callback function :type callback: function - + .. helptext:: set a callback for when the tween completes + .. lua:method:: onSubComplete(callback) + + Sets a callback for each time the tween finishs a segment in the tween + + :param callback: The callback function + :type callback: function + + .. helptext:: set a callback for when a segment of the tween completes + .. lua:method:: seek(percent) Seeks the tween to a specific normalized time (percentage of duration) @@ -206,9 +233,9 @@ Here is a list of all easing functions * - ``backIn`` * - ``backOut`` * - ``backInOut`` - * - ``bounceIn`` - * - ``bounceOut`` - * - ``bounceInOut`` + * - ``bounceIn`` - only for ``tween`` + * - ``bounceOut`` - only for ``tween`` + * - ``bounceInOut`` - only for ``tween`` * - ``circularIn`` * - ``circularOut`` * - ``circularInOut`` @@ -227,4 +254,5 @@ Here is a list of all easing functions * - ``elasticIn`` * - ``elasticOut`` * - ``elasticInOut`` - * - ``punch`` \ No newline at end of file + * - ``punch`` + * - ``hold`` - only for ``animation.easing`` \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 8dcd284..0b03358 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -61,6 +61,7 @@ Codea 4 api/camera api/light api/tween + api/time api/ui api/motion api/require @@ -69,12 +70,15 @@ Codea 4 api/file api/physics2d api/physics3d + api/tilemap + api/animation api/pick api/viewer api/inspector api/device api/storage + Indices and tables ==================