help with sprite collision

Find quick help here to get you started with Hollywood
Post Reply
sesco
Posts: 36
Joined: Tue Oct 18, 2011 6:40 am
Location: Toronto, Canada

help with sprite collision

Post by sesco » Sun May 01, 2016 5:56 pm

I'm getting the error ' Sprite 0 is not on screen!' for this collision check below but I only defined Sprites 1,2, and 3 :?:

-----------------------------------------------------------------------
If Collision(#SPRITE, sprite1, sprite3) = True
DisplaySprite(2, 0, 0)
Else
DisplaySprite(3, 0, 0)
EndIf
A1-X1000- I BELIEVE

User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: help with sprite collision

Post by fjudde » Sun May 01, 2016 7:40 pm

We need to see more of the code. Which values have you assigned to the variables sprite1 and sprite3? You need to give them the same number as the corresponding sprites

When I work with sprites I use constants with describing names instead of variables:

Code: Select all

@SPRITE 1, "I-PointBlack.png", {Transparency = #WHITE}
Const #Ipoint = 1
@SPRITE 2, "Sword32x20transWhite.png", {Transparency = #WHITE}
Const #Sword = 2
And then I use the constants throughout the program when referring to the sprites

Code: Select all

If Collision(#SPRITE, #Sword, #Ipoint) = True
    ...do stuff...
EndIf
Makes it easier to read your own code later on when sprite are described with names instead of numbers or digits.
_____________________________________
Hollywood 6.1

User avatar
fjudde
Posts: 20
Joined: Tue Dec 01, 2015 2:59 pm
Location: Stockholm, Sweden

Re: help with sprite collision

Post by fjudde » Mon May 02, 2016 5:25 pm

fjudde wrote: When I work with sprites I use constants with describing names instead of variables:

Code: Select all

@SPRITE 1, "I-PointBlack.png", {Transparency = #WHITE}
Const #Ipoint = 1
...
Well, this is even better, the constants first!

Code: Select all

Const #Ipoint = 1
@SPRITE #Ipoint, "I-PointBlack.png", {Transparency = #WHITE}
I should have done it this way earlier :roll: Well never too late to change.
_____________________________________
Hollywood 6.1

Post Reply