Hello!
My problem is:
For example I create polygon in editor (record every vertexes in array), and I want to save it. In next time I want to load polygon, that I save, in some different point.
I know how save array. But I don't , how recreate (with what attributes) polygon.
Please help! Thanks!)
I post attachments with my example programms (Simple Editor more easy to ).
[Solved] Save/Load physics objects
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
[Solved] Save/Load physics objects
- Attachments
-
- Simple Editor.love
- (1.35 KiB) Downloaded 47 times
-
- Editor.love
- (1.61 KiB) Downloaded 42 times
Last edited by Snuux on Wed Jul 23, 2014 5:32 am, edited 1 time in total.
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
Re: Save/Load physics objects
I Solve my problem. This is pseudo-code for saving.
And in next time, when we load objects with "s" coords, it's properly loads!
I attach example. Easy with mouse - create polygon. And in next time, load it with key "s"!
I use my library for saving, calling Slib. Feel free to use too.
Code: Select all
local o = {} --our object with o.b - body, o.s - shape, o.f - fixture
local s = {}
s = {o.s:getPoints()} --Get all points!
local cx, cy = o.b:getLocalCenter()
for i=1, #s, 2 do --And from every point subtract local center
s[i] = s[i] - cx
s[i+1] = s[i+1] - cy
end
Slib.save(s)
I attach example. Easy with mouse - create polygon. And in next time, load it with key "s"!
I use my library for saving, calling Slib. Feel free to use too.
- Attachments
-
- SavePolygon.love
- "s" to load polygon
- (3.71 KiB) Downloaded 46 times
My library for easy saving Slib! Try this! Now you can encrypt your save!
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
- Drop of light LD#30
- OUTRANGE LD#31
(Sorry for my english. I learn it myself, and I don't have enough experience)
Who is online
Users browsing this forum: Bing [Bot] and 3 guests