Table of Contents

 
SetFrameValue
 

Purpose

Stores a new value in the specified frame

 

Protoype

void CSpriteMngr::SetFrameValue (int i_value, int i_frame, string str_anim_id = "", fbatch bf_frames = fbatch())
 

Parameters

value the new value of the frame
frame the frame to assign the new value
anim_id the ID of the animation to modify
frames a list of frames to assign the new value
 

Description

This function changes the value of a given frame of animation. What this allows you to do is modify animation sequences on the fly without having to reload them. You pass in a valid animation frame (function validates this as well) for i_frame and the new value to be stored in that frame for i_value. So if you have a sequence of {5, 7, 2, 7, 5} and wanted to change the 2 to a 6, you would pass in 2 for i_frame (remember, all animation sequences begin at 0) and a 6 for i_value. If you want this value to go into more than one frame, you can pass in a list of frame numbers for bf_frames and use ALL_FRAMES for i_frame. If there is already an animation loaded with LoadAnimation(), then you can set the value for that animation without having to specify it. However if there is no loaded animation or you want to access an animation not loaded, then you must pass in its ID for str_anim_id.

NOTE: There must be a locked sprite object in order for this function to work

 

Use

CSpriteMngr sprite;
// access loaded animation
sprite.SetFrameValue(6, 2);
// access another animation
sprite.SetFrameValue(6, 2, "nuther_anim");
// set this value for frames 2, 6, and 8
fbatch bf_frames;
bf_frames.push_back(2); 
bf_frames.push_back(6);
bf_frames.push_back(8); 
sprite.SetFrameValue(6, ALL_FRAMES, NO_ANIM, bf_frames); 
 

Prev: SetFrameDelay
Next: SetRepeat