NOGDUS
December 17, 2018, 01:45:10 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   Home   Blogs Help Search Tags Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: depth change  (Read 3141 times)
0 Members and 1 Guest are viewing this topic.
bedndarc
Member
*

Respect: 0
Offline Offline

Posts: 58



« on: July 11, 2010, 05:31:32 AM »

Whether there is a possibility to change depth of the sprite, except as loading order?

And in additives how to kill the object? (An example: the shell has got, the game object has perished, it needs to be deleted from the screen).
Logged
Mattias Gustavsson
Moderator
Member
*

Respect: 58
Offline Offline

Posts: 94



« Reply #1 on: July 12, 2010, 05:37:22 PM »

That's actually quite easy - just call SetPriority on the sprite, and pass in a number as parameter. Sprites with a higher number is then drawn in front of sprites with a lower number.

To remove a sprite, you just need to delete it - so if you called something like "mySprite_=new Sprite()" to create it, you just do "delete mySprite" to remove it. You could also call SetVisible(false) on a sprite to temporarily hide it, and then SetVisible(true) to show it again
Logged
bedndarc
Member
*

Respect: 0
Offline Offline

Posts: 58



« Reply #2 on: July 13, 2010, 12:43:42 AM »

thanks Smiley
If I have correctly understood:
modification depth sprite: mySprite_.SetPriority=1;
kill: delete mySprite_
-----------------------------------------------------
Question not on a theme, but at the same time. Whether It is possible at animated sprites to specify, which shot to show, and whether it is possible to specify a range of shots for display?
If yes, it essentially facilitates a life. For example in one graphic file to store all animation sequences, and to specify only what it is necessary. If I am not mistaken so worked strip formats.
Logged
Mattias Gustavsson
Moderator
Member
*

Respect: 58
Offline Offline

Posts: 94



« Reply #3 on: July 13, 2010, 03:13:01 AM »

Yes, that's almost correct, but SetPriority is a function, so it is mySprite_.SetPriority(1); and you can only delete mySprite_ if it is a pointer and you created it using "new".
Example: in class declaration (.h file), you would have:
Sprite* mySprite_;
and when you want to create the sprite you'd do
mySprite_=new Sprite();
and to destroy it you would do:
delete mySprite_;
but keep in mind, since you'll be using a pointer to a sprite, you would not use "." to call functions on it, but "->" instead, like this:
mySprite->SetPriority(1);

If you have a BitmapStrip with multiple images, and set that as the bitmap for a sprite using Sprite::SetBitmap, the sprite will display the first image of the strip. You can call Sprite::SetCel to change which image it displays, so you have full control of how to display animations.

Personally, I like to make a separate bitmapstrip for every animation, as I find it easier to work with, but you don't have to do it like that - just call SetCel to change the image, and your own logic to decide what to display.
Logged
Tags:
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines Valid XHTML 1.0! Valid CSS!