I guess I thought that using return; would be the value of the last thing a function returned.
My next question is that how you can make a bullet fly in a wavy motion? I know I need to use ObjMove_SetAngularVelocity(id, r);. I was hoping to make it so that the wavy motion started small and as the bullet travels further, the it would start waving further to each side.
You should make the change angular velocity as well as the time between shifts dependent on time. I would have a descent loop that waits the number of frames in the loop constant, with the angular velocity likewise being dependent on the constant.
EDIT: Didn't realize there was already a code-based answer
How would I add a sprite for a boss that is in a sprite sheet?
What are you trying to do? If you have a sprite sheet and want to animate the boss, then you'll need to determine the dimensions of each sprite, then change the source rect in your Render Object depending on how much time has passed.
Below is an example the code I use. I have 4 128x128 sprites in a row that form the animation, and four states to represent idle/left/right/cast (the first row is idle, the second is left, etc). I've removed the cast/attack animation logic from the snippet below to make it shorter.
let TDRAWSTATE_IDLE = 0;
let TDRAWSTATE_LEFT = 1;
let TDRAWSTATE_RGHT = 2;
task TDrawLoop(path){
let animframe = 1;
let movestate = TDRAWSTATE_IDLE;
ObjPrim_SetTexture(objBoss, path);
ObjRender_SetScaleXYZ(objBoss, 1, 1, 1);
let bossAngle = ObjMove_GetAngle(objBoss);
let bossSpeed = ObjMove_GetSpeed(objBoss);
ObjSprite2D_SetSourceRect(objBoss, 0, 0, 128, 128);
ObjSprite2D_SetDestCenter(objBoss);
while(!Obj_IsDeleted(objBoss)){
bossAngle = ObjMove_GetAngle(objBoss) % 360;
bossSpeed = ObjMove_GetSpeed(objBoss);
if(bossSpeed > 0){ //below three cases require if statement to prevent reset of animframe.
if((bossAngle > 270 || bossAngle < 90) && movestate != TDRAWSTATE_RGHT){
movestate = TDRAWSTATE_RGHT;
animframe = 0;
}else if((bossAngle > 90 && bossAngle < 270) && movestate != TDRAWSTATE_LEFT){
movestate = TDRAWSTATE_LEFT;
animframe = 0;
}else if((bossAngle == 90 || bossAngle == 270) && movestate != TDRAWSTATE_IDLE){
movestate = TDRAWSTATE_IDLE;
animframe = 0;
}
}else if(movestate != TDRAWSTATE_IDLE){ //if transitioning back to idle (speed = 0)
movestate = TDRAWSTATE_IDLE;
animframe = 0;
}
ObjSprite2D_SetSourceRect(objBoss, 0+floor(animframe/9)*128, 0 + 128*movestate, 128 + floor(animframe/9)*128, 128 + 128*movestate);
animframe++;
if(animframe >= 36){
if(movestate == TDRAWSTATE_IDLE){ //animframe reset for idle
animframe = 0;
}else{ //keep in current position if moving.
animframe = 35;
}
}
yield;
}
}
Essentially, we have 128x128 sprites and the one we choose is dependent on animframe (9 frames per image, 4 images = 36 frames before we reset the idle animation). For my left and right movement, I keep the animation in the last image after the opening sequence plays, hence maintaining animframe at 35 at the end. If the boss is not moving, then they will not be kept in a movement state.
The line that handles choosing which sprite to use is the following:
ObjSprite2D_SetSourceRect(objBoss, 0+floor(animframe/9)*128, 0 + 128*movestate, 128 + floor(animframe/9)*128, 128 + 128*movestate);
floor(animframe/9)*128 represents which frame to use (first, second, third, or fourth) in the spreadsheet, while 128*movestate represents which animation to use (idle, left, right, or cast).
I hope this gives you a better sense of how to animate your sprite sheet.