Can't set Mouse Cursor to a Dynamic Sprite (Solved)

Started by Colxfile, Mon 26/06/2006 14:53:05

Previous topic - Next topic

Colxfile

It appears that Changing the cursor graphic to a DynamicSprite causes a problem.

I first started with this:
Code: ags

mouse.ChangeModeGraphic(eModePointer, oMysub.Graphic);


Now, this does work. But since the graphic I'm using needs cropping, I cropped it using the DynamicSprite's Crop function and passed the resulting graphic as the one to use as the mouse pointer. The game compiled fine, but when I ran the function in question, the game quit with the following error:
Quote from: Error message.
---------------------------
Illegal exception
---------------------------
An exception 0xC0000005 occured in ACWIN.EXE at EIP = 0x00427E88 ; program pointer is +5, ACI version 2.72.918, gtags (0,0)

AGS cannot continue, this exception was fatal. Please note down the numbers above, remember what you were doing at the time and ... etc
---------------------
OKÃ,  Ã, 
---------------------

I played around with cropping the sprite more or less, until I discovered that even this wouldn't work at all (despite basically being the same as the above code)
Code: ags

DynamicSprite *my_sub_sprite = DynamicSprite.CreateFromExistingSprite(oMysub.Graphic);
Mouse.ChangeModeGraphic(eModePointer, my_sub_sprite.Graphic);


I tried it out with RC2a and still the same trouble. Hope this helps.
Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

SSH

Quote from: Colxfile on Mon 26/06/2006 14:53:05

Code: ags

DynamicSprite *my_sub_sprite = DynamicSprite.CreateFromExistingSprite(oMysub.Graphic);
Mouse.ChangeModeGraphic(eModePointer, my_sub_sprite.Graphic);


I tried it out with RC2a and still the same trouble. Hope this helps.

Since this code was presumably inside a function, as soon as the function ended my_sub_sprite would have gone out of scope and thus been deleted... hence your error. All non-temporary dynamic sprites must be global variables decleared outside of any function.
12

Colxfile

Always carry a UV marker pen with you. When you go to a shop or a friend's house, if you see something you like, put your name and postcode on it. If it gets stolen and subsequently recovered, the police will get in touch with you so that they can 'return' it.

riseryn

where are you declaring dynamic sprite to  make them global?

I tried out of a function in the beginning of global script and I get this error

---------------------------
Compile Error
---------------------------
There was an error compiling your script. The problem was:

In: 'Global script'



Error (line 31): cannot assign initial value to global pointer



Do you want to fix the script now? (Your game has not been saved).


Khris

Did you read the error message?
Do "DynamicSprite*ds;" outside any function, then assign something to it in game_start or whenever.

riseryn

Thanks KhrisMUC
I have not understand the meaning of the error message but your answer make it clearer.
now it 's good :)

thanks again to you and every member who helps newbies with silly questions :)

SMF spam blocked by CleanTalk