? CALL/CALLIDX/SPCOL? (Page 1) ● SmileBASIC Source Forums

Sign In

Register
*Usernames are case-sensitive
Forgot my password

CALL/CALLIDX/SPCOL?

  • #1 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies I’m making a game and on the touchscreen i have like 20 sprites that all need individual functionality so how would i do that using touch? Like if i tap one it will make it red and if i tap another one it’ll make it red and the previously tapped one white again. But on top of the color changing would be additional top screen stuff. what do i do? Examples? Posted
  • #2 ✎ 1614 12Me21 Head Admin Second Year My account is over 2 years old Website Syntax Highlighter Received for creating the code syntax highlighter on SBS Night Person I like the quiet night and sleep late. Express Yourself You can use SPHITRC to check if any sprites are inside a rectangular area: sprite_id = SPHITRC( rectangle_x , rectangle_y , rectangle_width , rectangle_height ) So, if you're trying to see which sprite is being touched, just use the touch coordinates as the rectangle position. Posted
  • #3 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    You can use SPHITRC to check if any sprites are inside a rectangular area: sprite_id = SPHITRC( rectangle_x , rectangle_y , rectangle_width , rectangle_height ) So, if you're trying to see which sprite is being touched, just use the touch coordinates as the rectangle position.
    Yeah but i need to be able to move the sprites around. I was thinking more invisible sprite to visible sprite on the touchscreen collision. I was told that CALL and CALLIDX were crucial to doing what i need. How do those work?
    Posted
  • #4 ✎ 131 raimondz First Week Joined in the very first week of SmileBASIC Source Website Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself "CALL sprite" will call any label or function assigned to each sprite using SPFUNC. You should use it if you're not using any auxiliar variable(AKA metadata) to represent your sprite. Example: VAR SP1=SPSET(0) VAR SP2=SPSET(1) SPFUNC SP1,"A" SPFUNC SP2,"B" 'This sentence will call the functions associate with each sprite. CALL sprite DEF A ? CALLIDX END DEF B ? "SPRITE NUMBER = ";CALLIDX END By the way, I wouldn't use "CALL sprite" to do that. You can save the sprite obtained with sphitrc and move it with spofs if the touch time is greater than 1. If the touch time is one and the sprite's management number is different to the one stored, then you can change the color of the old one and store the new sprite's management number on that variable. Posted Edited by raimondz
  • #5 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    "CALL sprite" will call any label or function assigned to each sprite using SPFUNC. You should use it if you're not using any auxiliar variable(AKA metadata) to represent your sprite. Example: VAR SP1=SPSET(0) VAR SP2=SPSET(1) SPFUNC SP1,"A" SPFUNC SP2,"B" 'This sentence will call the functions associate with each sprite. CALL sprite DEF A ? CALLIDX END DEF B ? "SPRITE NUMBER = ";CALLIDX END By the way, I wouldn't use "CALL sprite" to do that. You can save the sprite obtained with sphitrc and move it with spofs if the touch time is greater than 1. If the touch time is one and the sprite's management number is different to the one stored, then you can change the color of the old one and store the new sprite's management number on that variable.
    Ah ok i think i understand. I’ll try that.
    Posted
  • #6 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    "CALL sprite" will call any label or function assigned to each sprite using SPFUNC. You should use it if you're not using any auxiliar variable(AKA metadata) to represent your sprite. Example: VAR SP1=SPSET(0) VAR SP2=SPSET(1) SPFUNC SP1,"A" SPFUNC SP2,"B" 'This sentence will call the functions associate with each sprite. CALL sprite DEF A ? CALLIDX END DEF B ? "SPRITE NUMBER = ";CALLIDX END By the way, I wouldn't use "CALL sprite" to do that. You can save the sprite obtained with sphitrc and move it with spofs if the touch time is greater than 1. If the touch time is one and the sprite's management number is different to the one stored, then you can change the color of the old one and store the new sprite's management number on that variable.
    So i used this code and using either CALL”A” or CALL”B” Always resulted the CALLIDX value in each function as 0. I was doing this as a test and i don’t know why that doesn’t work, CALL”A” should give me “0” andCALL”B”should give me “SPRITE NUMBER = 1” shouldn’t it?
    Posted
  • #7 ✎ 930 Y_ack CALL SPRITE evaluates each function attached to sprites with SPFUNC, updating CALLIDX. Ordinary call will not work. Posted
  • #8 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    CALL SPRITE evaluates each function attached to sprites with SPFUNC, updating CALLIDX. Ordinary call will not work.
    So what do i need to do then besides CALL?
    Posted
  • #9 ✎ 930 Y_ack Like others have said, you don't really need SPFUNC to do this: SPHIT* returns the collision ID. SPFUNC is useful when you want to automatically evaluate the state of all sprites, which you're not doing here. DEF MySpriteFunction ID SPCOLOR ID, #RED 'etc END WHILE 1 TOUCH OUT TTIME, TX, TY IF TTIME > 0 && SPHITRC(TX, TY, 1, 1) != -1 THEN MySpriteFunction SPHITRC(TX, TY, 1, 1) ENDIF WEND something like this probably works Posted Edited by Y_ack
  • #10 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    RTFM DEF MySpriteFunction ID SPCOLOR ID, #RED 'etc END WHILE 1 TOUCH OUT TTIME, TX, TY IF TTIME > 0 && SPHITRC(TX, TY, 1, 1) != -1 THEN MySpriteFunction SPHITRC(TX, TY, 1, 1) ENDIF WEND something like this probably works
    This doesn’t work?? I’m trying to find out why, probably something i did
    Posted
  • #11 ✎ 930 Y_ack
    RTFM DEF MySpriteFunction ID SPCOLOR ID, #RED 'etc END WHILE 1 TOUCH OUT TTIME, TX, TY IF TTIME > 0 && SPHITRC(TX, TY, 1, 1) != -1 THEN MySpriteFunction SPHITRC(TX, TY, 1, 1) ENDIF WEND something like this probably works
    This doesn’t work?? I’m trying to find out why, probably something i did
    What's the error given?
    Posted
  • #12 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    RTFM DEF MySpriteFunction ID SPCOLOR ID, #RED 'etc END WHILE 1 TOUCH OUT TTIME, TX, TY IF TTIME > 0 && SPHITRC(TX, TY, 1, 1) != -1 THEN MySpriteFunction SPHITRC(TX, TY, 1, 1) ENDIF WEND something like this probably works
    This doesn’t work?? I’m trying to find out why, probably something i did
    What's the error given?
    There wasn’t any syntax errors, it just doesn’t work?? I’m making a test program right now to see if i did something wrong. I think i know what i did but let me check.
    Posted
  • #13 ✎ 930 Y_ack
    There wasn’t any syntax errors, it just doesn’t work?? I’m making a test program right now to see if i did something wrong. I think i know what i did but let me check.
    Check the specification for TOUCH and SPHITRC. I've never used them, so I can't be sure.
    Posted
  • #14 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    RTFM DEF MySpriteFunction ID SPCOLOR ID, #RED 'etc END WHILE 1 TOUCH OUT TTIME, TX, TY IF TTIME > 0 && SPHITRC(TX, TY, 1, 1) != -1 THEN MySpriteFunction SPHITRC(TX, TY, 1, 1) ENDIF WEND something like this probably works
    This doesn’t work?? I’m trying to find out why, probably something i did
    What's the error given?
    There wasn’t any syntax errors, it just doesn’t work?? I’m making a test program right now to see if i did something wrong. I think i know what i did but let me check.
    Ok so i created a new test file folder and started up a new program without anything in it and ran:ACLS XSCREEN 2 DEF SELECT ID SPCOLOR ID,#RED END DISPLAY 1 SPSET 1,1 SPOFS 1,150,100 WHILE 1 TOUCH OUT TTIME,TX,TY IF TTIME > 0 && SPHITRC(TX,TY,1,1) != -1 THEN SELECT SPHITRC(TX,TY,1,1) ENDIF WEND Nothing happens when i touch it.
    Posted
  • #15 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    There wasn’t any syntax errors, it just doesn’t work?? I’m making a test program right now to see if i did something wrong. I think i know what i did but let me check.
    Check the specification for TOUCH and SPHITRC. I've never used them, so I can't be sure.
    We are using correct syntax
    Posted
  • #16 ✎ 930 Y_ack oh um you're missing SPCOL, I think. Posted
  • #17 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies
    oh um you're missing SPCOL, I think.
    YES that was the problem dont embarrass me like that again lmao
    Posted
  • #18 ✎ 165 MochaProbably Expert Programmer Programming no longer gives me any trouble. Come to me for help, if you like! Programming Strength Night Person I like the quiet night and sleep late. Express Yourself Drawing I like to draw! Hobbies So anyways now that is working i should probably put up a tutorial of some sort to not only remind me but tell other people how to do stuff like i am, where there’s a bunch of things on screen that all have individual assets. Posted