megalanthusdefold-gamepush
megalanthus/defold-gamepush/gamepush.core.images
GamePush images: upload, choose, fetch and resize player images, with their events.
- GitHub: megalanthus/defold-gamepush — pinned to
v1.4.1- Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged
.zipasset, if the library ships one) togame.projectunder[project]dependencies, then Fetch Libraries in the Defold editor. - Run
bunx @defold-typescript/cli resolveto materialize its types. - Import it under a namespace alias of your choice:
import * as core_images from "gamepush.core.images"
- Pick a release from megalanthus/defold-gamepush releases and add its Source code (zip) URL (or a packaged
Functions
upload(parameters: Record<string, unknown>, callback?: (image: unknown) => void)upload_url(parameters: Record<string, unknown>, callback?: (image: unknown) => void)choose_file(callback?: (result: unknown) => void)choice_file(callback?: (result: unknown) => void)fetch(parameters?: Record<string, unknown>, callback?: (result: unknown) => void)fetch_more(parameters?: Record<string, unknown>, callback?: (result: unknown) => void)resize(uri: string, width?: number, height?: number, crop?: boolean): stringcan_upload(): boolean
upload(parameters: Record<string, unknown>, callback?: (image: unknown) => void)
Uploads an image the player chooses. Raises when the table is missing.
Parameters
parameters:Record<string, unknown>— The upload options, for example{ tags: ["screenshot", "level7"] }.callback?:(image: unknown) => void— Receives the image.
upload_url(parameters: Record<string, unknown>, callback?: (image: unknown) => void)
Uploads an image from a URL. Raises when the table is missing.
Parameters
parameters:Record<string, unknown>— The upload options, including the image'surl.callback?:(image: unknown) => void— Receives the image.
choose_file(callback?: (result: unknown) => void)
Asks the player to choose an image.
Parameters
callback?:(result: unknown) => void— Receives the result.
choice_file(callback?: (result: unknown) => void)
- Deprecated — Use
choose_fileinstead.
Asks the player to choose an image.
Parameters
callback?:(result: unknown) => void— Receives the result.
fetch(parameters?: Record<string, unknown>, callback?: (result: unknown) => void)
Fetches images.
Parameters
parameters?:Record<string, unknown>— The fetch options.callback?:(result: unknown) => void— Receives the result.
fetch_more(parameters?: Record<string, unknown>, callback?: (result: unknown) => void)
Fetches more images.
Parameters
parameters?:Record<string, unknown>— The fetch options.callback?:(result: unknown) => void— Receives the result.
resize(uri: string, width?: number, height?: number, crop?: boolean): string
Resizes an image and returns the link to the resized copy.
Parameters
uri:string— The image's address.width?:number— The width to resize to.height?:number— The height to resize to.crop?:boolean— Whether to crop the image.
Returns
string
can_upload(): boolean
Whether the player can upload images.
Returns
boolean
Variables
callbacks: ImagesCallbacks
The event handlers.
Types
ImagesCallbacks
ImagesCallbacks.upload?: (image: unknown) => void
An image was uploaded.
ImagesCallbacks.error_upload?: (error: unknown) => void
Uploading an image failed.
ImagesCallbacks.choose?: (result: unknown) => void
The player chose an image.
ImagesCallbacks.error_choose?: (error: unknown) => void
Choosing an image failed.
ImagesCallbacks.fetch?: (result: unknown) => void
The images were fetched.
ImagesCallbacks.error_fetch?: (error: unknown) => void
Fetching the images failed.
ImagesCallbacks.fetch_more?: (result: unknown) => void
More images were fetched.
ImagesCallbacks.error_fetch_more?: (error: unknown) => void
Fetching more images failed.