[PLUGIN] Sprite Bank

Post your completed addons to share with the community

Post » Tue Dec 27, 2011 10:54 am

The new version of sprite bank had been released named instance bank.


Sprite Bank
(update:2012/05/11)

To save some properties of sprite instances(save instances into bank), then create instance and set these properties(load instances from bank). A kind of serialization of sprite instance.

The chart of how to use it is -

"Action: Save instances": saving properties of instances into bank
"Action: Load instances": create instances and set properties from bank
"Expression: BankToString": transfer bank to JSON string
"Action: Load bank": transfer JSON string to bank

The saved properties are
- inst.x
- inst.y
- inst.width
- inst.height
- inst.angle
- inst.opacity
- inst.visible
- inst.cur_frame
- inst.private variables
- inst.layer
- inst.cur_animation.name
- custom data (*option)

Example

For advance user, sprite bank provides calling function plugin when save/create instance. (See test_sprite_bank_adv.capx in example) It can do some custom actions like save/restore properties in behavior.
On saving instance, put data into return[name].
On creating instance, get data from prame(name).
So you can save the speed of bullet behavior then restore it when created.
Actually, the string of callback not only a function name, but also a command used in "action:execute commands", so you can put some parameters in the string.rexrainbow2013-01-19 09:19:03
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Tue Dec 27, 2011 12:34 pm

Wow Thanks!!! Im not sure what to use it for though? What does it save a sprites position or just its existence?
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Dec 27, 2011 1:25 pm

God bless Rex ^^
B
159
S
38
G
11
Posts: 229
Reputation: 17,361

Post » Tue Dec 27, 2011 1:37 pm

@smitchell
The plugin is to save the position(and some other porperties).
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Tue Dec 27, 2011 2:04 pm

Ahh cool, So for like rpg's you could save the exact position then on return of game load that position?
B
29
S
12
G
7
Posts: 740
Reputation: 7,849

Post » Tue Dec 27, 2011 3:09 pm

@smitchell

Yes, it can do that (save the exact position then on return of game load that position).
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Wed Dec 28, 2011 12:27 am

Do I miss any important property of sprite?rexrainbow2011-12-28 00:27:24
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Wed Dec 28, 2011 6:17 am

[QUOTE=rexrainbow] Do I miss any important property of sprite?[/QUOTE]
Flipped, mirrored perhaps?
Image Image
B
161
S
48
G
91
Posts: 7,359
Reputation: 67,273

Post » Wed Dec 28, 2011 6:18 am

@newt

Thnaks, I will add these.
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Post » Wed Dec 28, 2011 8:29 am

@newt

I check the "Flipped, mirrored" in sprite plugin. It seems to use
- (width <0):mirrored
- (height < 0):flipped

So current sprite bank can record these two properties by saving width and height.
B
97
S
22
G
178
Posts: 4,122
Reputation: 104,051

Next

Return to Completed Addons

Who is online

Users browsing this forum: No registered users and 0 guests