Run In N Frames
Hierarchy
-
Feature
↳
RunInNFrames
Methods
vConditionalFunc
▸ vConditionalFunc(): boolean
Returns
boolean
Overrides
Feature.vConditionalFunc
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:43
restartNextRenderFrame
▸ restartNextRenderFrame(character?
): void
Helper function to restart on the next render frame. Useful because it is impossible to restart
the game inside of the POST_NEW_ROOM
, POST_NEW_LEVEL
, or POST_GAME_STARTED
callbacks when
a run is first starting.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Description |
---|---|---|
character? | PlayerType | Optional. If specified, will restart the game as the specified character. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:109
runInNGameFrames
▸ runInNGameFrames(func
, numGameFrames
, cancelIfRoomChanges?
): void
Supply a function to run N game frames from now in the POST_UPDATE
callback.
For a usage example, see the documentation for the runNextGameFrame
, which is used in a
similar way.
Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => void | undefined | The function to run. |
numGameFrames | int | undefined | The amount of game frames to wait before running the function. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:134
runInNRenderFrames
▸ runInNRenderFrames(func
, numRenderFrames
, cancelIfRoomChanges?
): void
Supply a function to run N render frames from now in the POST_RENDER
callback.
For a usage example, see the documentation for the runNextGameFrame
, which is used in a
similar way.
Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => void | undefined | The function to run. |
numRenderFrames | int | undefined | The amount of render frames to wait before running the function. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:171
runNextGameFrame
▸ runNextGameFrame(func
, cancelIfRoomChanges?
): void
Supply a function to run on the next POST_UPDATE
callback.
For example:
const NUM_EXPLODER_EXPLOSIONS = 5;
function useItemExploder(player: EntityPlayer) {
playSound("exploderBegin");
explode(player, NUM_EXPLODER_EXPLOSIONS);
}
function explode(player: EntityPlayer, numFramesLeft: int) {
Isaac.Explode(player, undefined, 1);
numFramesLeft -= 1;
if (numFramesLeft === 0) {
runNextFrame(() => {
explode(player, numFramesLeft);
});
}
}
Note that this function will not handle saving and quitting. If a player saving and quitting before the deferred function fires would cause a bug in your mod, then you should handle deferred functions manually using serializable data.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => void | undefined | The function to run. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:225
runNextRenderFrame
▸ runNextRenderFrame(func
, cancelIfRoomChanges?
): void
Supply a function to run on the next POST_RENDER
callback.
For a usage example, see the documentation for the runNextGameFrame
, which is used in a
similar way.
Note that this function will not handle saving and quitting.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => void | undefined | The function to run. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:245
setIntervalGameFrames
▸ setIntervalGameFrames(func
, numGameFrames
, runImmediately
, cancelIfRoomChanges?
): void
Supply a function to be repeatedly run on an interval of N game frames in the POST_UPDATE
callback. The function will continue to be fired until false
is returned from the function.
This is similar to the setInterval
vanilla JavaScript function, except there is no
corresponding clearInterval
function. (Instead, the return value from the supplied function
is used to stop the interval.)
Note that this function will not handle saving and quitting. You must manually restart any intervals if the player saves and quits in the middle of a run.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => boolean | undefined | The function to repeatedly run on an interval. |
numGameFrames | int | undefined | The amount of game frames to wait between each run. |
runImmediately | boolean | undefined | Whether to execute the function right now before waiting for the interval. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:274
setIntervalRenderFrames
▸ setIntervalRenderFrames(func
, numRenderFrames
, runImmediately
, cancelIfRoomChanges?
): void
Supply a function to be repeatedly run on an interval of N render frames in the POST_RENDER
callback. The function will continue to be fired until false
is returned from the function.
This is similar to the setInterval
vanilla JavaScript function, except there is no
corresponding clearInterval
function. (Instead, the return value from the supplied function
is used to stop the interval.)
Note that this function will not handle saving and quitting. You must manually restart any intervals if the player saves and quits in the middle of a run.
In order to use this function, you must upgrade your mod with ISCFeature.RUN_IN_N_FRAMES
.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
func | () => boolean | undefined | The function to repeatedly run on an interval. |
numRenderFrames | int | undefined | The amount of game frames to wait between each run. |
runImmediately | boolean | undefined | Whether to execute the function right now before waiting for the interval. |
cancelIfRoomChanges | boolean | false | Optional. Whether to cancel running the function if a new room is loaded in the interim. Default is false. |
Returns
void
Defined in
packages/isaacscript-common/src/classes/features/other/RunInNFrames.ts:322