Hi All,
The below code (sorry - you need to create two really simple sprites) creates random dots all over another sprite that is rotating and that can be scaled too - it works exactly as I want it to (it's for generating death splashes on monsters)... EXCEPT that if I also add a sprite offset (which I need to do for my game) it breaks. Can someone help me figure out what extra line(s) of code I need?
SetWindowSize( 1920, 1080, 0 )
SetVirtualResolution( 1920, 1080) // doesn't have to match the window
// --------------------------- LOAD TWO SIMPLE SPRITES ---------------------------------------
BarSprite = CreateSprite(LoadImage("Bar.png")) // A simple rectangle 1000px wide and 100px tall
BallSprite = CreateSprite(LoadImage("Ball.png")) // A simple 16px by 16px dot
Balls As Integer[500]
For Cycle = 1 to 500
Balls[Cycle] = CloneSprite(BallSprite) // Create 500 ball sprites for positioning later
Next Cycle
Width = GetSpriteWidth(BarSprite) / 2
SetSpriteScale(BarSprite, 0.5, 0.5)
SetSpritePositionByOffset(BarSprite, 960, 540)
//SetSpriteOffset(BarSprite, 100, 100) // <------------------ ADD THIS AND IT GOES WRONG !!!!!!!!!!!!!!
Do
// ---------- Rotate the bar to check it is working ok ------------------------
BarAngle# = BarAngle# + (10 * GetFrameTime())
SetSpriteAngle(BarSprite, BarAngle#)
// ------------- Draw 500 dots inside the bar sprite ----------------
For Cycle = 1 to 500
LocX = RandomSign(Random(0, (GetSpriteWidth(BarSprite)/2))) // Find a random location within the sprite's boundaries on the X axis
LocY = RandomSign(Random(0, (GetSpriteHeight(BarSprite)/2))) // Find a random location within the sprites boundaries on the Y axis
NewLocX = GetWorldXFromSprite(BarSprite, LocX , LocY ) // Convert the above location to the altered sprites position on X
NewLocY = GetWorldYFromSprite(BarSprite, LocX , LocY ) // Convert the above location to the altered sprites position on Y
SetSpritePositionByOffset(Balls[Cycle], NewLocX, NewLocY)
Next Cycle
Sync()
Loop
Using Tier 1 AppGameKit V2
Started coding with AMOS (Thanks Francois Lionet)