Tiny Space dev diary

New to Moai? Get started here with our best tips and tutorials.

Re: Starting out feedback.

Postby ibisum » Thu Aug 02, 2012 1:29 am

Did you use MOAIParticleEmitter.new() to get a new object back for use?

Sample:

Code: Select all
  1.  

  2. -- render particles from new texture

  3.         function particles_smoke(pX,pY,pTexture)

  4.  

  5.                 CONST = MOAIParticleScript.packConst

  6.                 local PARTICLE_X1 = MOAIParticleScript.packReg(1)

  7.                 local PARTICLE_Y1 = MOAIParticleScript.packReg(2)

  8.                 local PARTICLE_R0 = MOAIParticleScript.packReg(3)

  9.                 local PARTICLE_R1 = MOAIParticleScript.packReg(4)

  10.                 local PARTICLE_S0 = MOAIParticleScript.packReg(5)

  11.                 local PARTICLE_S1 = MOAIParticleScript.packReg(6)

  12.  

  13.                 system2 = MOAIParticleSystem.new()

  14.                 system2:reserveParticles(256, 2)

  15.                 system2:reserveSprites(256)

  16.                 system2:reserveStates(1)

  17.                 system2:setDeck(pTexture)

  18.                 system2:start()

  19.  

  20.                 emitter2 = MOAIParticleDistanceEmitter.new()

  21.                 emitter2:setLoc(0, 0)

  22.                 emitter2:setSystem(system2)

  23.                 emitter2:setMagnitude(0.125)

  24.                 emitter2:setAngle(260, 280)

  25.                 emitter2:setDistance(4)

  26.                 emitter2:start()

  27.  

  28.                 state1 = MOAIParticleState.new()

  29.                 state1:setTerm(0, 1.25)

  30.                 particle_layer:insertProp(system2)

  31.                 --world_partition:insertProp(system2)

  32.  

  33.                 local init = MOAIParticleScript.new()

  34.                 init:rand( PARTICLE_X1, CONST(pX+2), CONST(pX-2))

  35.                 init:rand( PARTICLE_Y1, CONST(pY+2), CONST(pY-2))

  36.                 init:rand( PARTICLE_S0, CONST(pX), CONST(pX))

  37.                 init:rand( PARTICLE_S1, CONST(pY), CONST(pY))

  38.                 local render = MOAIParticleScript.new()

  39.                 render:ease( MOAIParticleScript.PARTICLE_X, MOAIParticleScript.PARTICLE_DX, PARTICLE_X1, MOAIEaseType.LINEAR)

  40.                 render:ease( MOAIParticleScript.PARTICLE_Y, MOAIParticleScript.PARTICLE_DY, PARTICLE_Y1, MOAIEaseType.LINEAR)

  41.  

  42.                 render:sprite()

  43.                 render:ease( MOAIParticleScript.SPRITE_X_SCL, CONST(0.1), CONST(1),MOAIEaseType.EASE_IN)

  44.                 --render:rand(MOAIParticleScript.SPRITE_X_SCL, CONST(0), CONST(0.5))

  45.                 --render:rand(MOAIParticleScript.SPRITE_Y_SCL, CONST(0), CONST(1))

  46.                 render:ease(MOAIParticleScript.SPRITE_Y_SCL, CONST(0.1), CONST(1),MOAIEaseType.EASE_IN)

  47.                 render:ease(MOAIParticleScript.SPRITE_OPACITY, CONST(1), CONST(0.6),MOAIEaseType.EASE_IN)

  48.                 --render:rand(MOAIParticleScript.SPRITE_ROT, CONST(-180), CONST(180))

  49.  

  50.                 state1:setInitScript(init)

  51.                 state1:setRenderScript(render)

  52.                 system2:setState(1, state1)

  53.  

  54.                 system2:surge(16,pX,pY,pX,pY)

  55.         end

  56.  

;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Thu Aug 02, 2012 1:54 am

Yep that's what i was trying to do, or am i supposed to use MOAI particle distance emitter? as i havent seen any samples just using MOAIParticleEmitter.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby ibisum » Thu Aug 02, 2012 2:28 am

I think (please someone more knowledgeable correct this if I am wrong) that MOAIParticleEmitter is just the base class for the other two, and you should use whichever of the 'child' classes most closely reflects your requirements for particles..
;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Thu Aug 02, 2012 3:38 pm

Hmm true. It's shit like this that should be mentioned in the documentation...
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby sgeos » Thu Aug 02, 2012 7:44 pm

Muzz wrote:that should be mentioned in the documentation...

You can see how the classes relate to one another on the MOAI SDK Class Hierarchy page.
Any original code posted by me is released via the CC0 Public Domain Dedication. It is in the public domain. Do whatever you want with it.
User avatar
sgeos
 
Posts: 241
Joined: Sat Apr 28, 2012 4:42 am
Location: Married in Japan.

Re: Starting out feedback.

Postby Muzz » Thu Aug 02, 2012 8:55 pm

I'm talking about from a perspective of someone who has never coded before, is it too much to ask to say in the class description something along the lines of "emitter class is only a parent, it cannot be used to make an emitter by itself". That stuff is intuitive if you have done it for a while. I'm literally stabbing in the dark.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby Muzz » Tue Aug 07, 2012 8:14 pm

Is there any examples on how to integrate moaigui into a project?
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby ibisum » Wed Aug 08, 2012 3:39 am

You can have a look at the multilayoutdemo.lua file that is included in the latest revisions of moaigui (in the git repo not in the samples/contrib/ tree of the main MOAI SDK..) I wrote that demo to show how multiple layouts can be called/used within an app, and it may provide you some clues.

Other than that, I guess I'd like to write a MOAIGUI tutorial that demonstrates the knowledge I gained by using the MOAIGUI framework for my apps .. something I will add to the list of 'things to write for MOAI' in the near future.. ;)
;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Wed Aug 08, 2012 6:04 am

Thanks! I'll let you know how it goes.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby ibisum » Wed Aug 08, 2012 11:31 pm

Lets hear how things progress!
;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Wed Aug 15, 2012 8:27 pm

Man! things are getting messy trying to integrate this stuff!

I got an error saying that g:loadlayoutfromdata didn't exist, so i changed it to load layout which does. Its building, but i dont know how to get it all showing on top of the game.

Hmm... Not sure how i can get help for this though.

I think i need somebody to actually look at my code and help me out. If someone is keen i can repay the favour with some art done. (say a logo or something you want to see drawn).
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby derickdong » Wed Aug 15, 2012 10:37 pm

I got an error saying that g:loadlayoutfromdata didn't exist

Are you using the Git version? I initially had the code uploaded to Google Code, and later moved it to Git. Unfortunately, this forum doesn't allow you to edit older posts, so I'm not able to update the link in the original post. The URL is further down in the thread, but here it is as well:

https://github.com/derickd/moaigui/downloads

but i dont know how to get it all showing on top of the game.

How do you handle adding layers? Do you use MOAISim.pushRenderPass or MOAIRenderMgr.pushRenderPass? If you are (and you shouldn't, as they've been deprecated), switch to MOAIRenderMgr.setRenderTable. This lets you set the order a list of MOAIRenderables, which MOAILayer and MOAILayer2D inherit from, will be rendered in. Get the gui layer through the GUI.layer function, and add it to the end of the list you pass to MOAIRenderMgr.setRenderTable. This will force the gui layer to be rendered last/on top.
derickdong
 
Posts: 63
Joined: Wed Nov 09, 2011 2:54 pm

Re: Starting out feedback.

Postby Muzz » Wed Aug 15, 2012 10:47 pm

I'm using the git version.

And thanks. I have been using MOAISim.pushRenderPass so ill give that a shot.

EDIT:

Ok so yeah i have absolutely no clue what I'm doing :/. I guess ill just keep plucking at it till i work it out. I dont understand how most of it works in the first place.

I guess this is what i get for choosing MOAI as a first coding experience haha.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby Muzz » Thu Aug 16, 2012 1:28 am

Ok so after banging my head against the wall all day i have no idea,

If anyone cares to have a look i'd be forever thankful. I apologise in advance for the messiness.

https://github.com/Muzz/tinyspace2
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby ibisum » Thu Aug 16, 2012 5:09 am

The first thing I see (after fixing DOS \\\\'s to the right-proper /'s in the gui framework, grr..) is the obvious missing layout_1.lua and layout_2.lua files. Alas, this may not be obvious, because for some reason I don't get any errors (moai just hangs on my linux-amd64 build, at this line#..), but without those layouts actually available, you won't get past line 162 of main.lua very easily ..

Is your intention to integrate moaigui into your game for things like settings and menu select and so on? Then you need to be aware that you have to use moaigui's layer manager and ensure that moaigui's layer, named "gui", is the last one on the stack (i.e. gets user interaction events) in order for it to work. The game layers are hierarchical and allow you to properly organize hit-point detection and so on in actual gameplay, but moaigui needs to be on the top of the stack to receive events, when you want to use it. Note that in main.lua, the mainThread could, in your game, simply be renamed "guiThread" and whenever you need the gui from your game side, you just tell the thread to insert/remove the gui layer (or switch to another layout) as needed.

EDIT: after some more inspection of tinyspace2, I see that you want to have a box2d physics environment .. if you intend to use moaigui as a layout manager (i.e. you might want GUI layouts all throughout your app) then you can instead do the physics in the layout code itself - i.e. instead of doing makeworld() in main.lua, do it in the layout_entry_handler() for the current layout. You can easily put box2d within the layout and have it function, but then switch to another layout when it comes time to go to another level/switch to new screen/show options dialog controls/etc.

Something like this:

(EDIT2: I fixed the borked code, renamed the layer_managers' "world_layer" to, of course, moaigui's "gui", as it should be..)

Code: Select all
  1.  

  2.   -- i.e. main.lua

  3. -- (world_layer = MOAILayer2D.new() & etc...)

  4. physics_layer = MOAILayer2D.new ()

  5. physics_layer:setViewport ( world_viewport )

  6. physics_layer:setCamera (world_camera )

  7.  

  8. layer_manager.addLayer("gui", 1, world_layer)

  9. layer_manager.addLayer("physics_layer", 99, physics_layer)

  10.  

  11.  



And then .. in a moaigui layout context, do this:

Code: Select all
  1.  

  2.     -- i.e. layout_1.lua

  3. function start_physics(winning_count)

  4.         --world_layer

  5.         -- set up the results_box2d_world and start its simulation

  6.         results_box2d_world = MOAIBox2DWorld.new ()

  7.         results_box2d_world:setGravity ( -2, -15 )

  8.         results_box2d_world:setUnitsToMeters ( 1 )

  9.         results_box2d_world:start ()

  10.  

  11.         local world_layer =     layer_manager.getLayer("physics_layer").moaiLayer

  12.         --world_layer:setPriority(1)

  13.        

  14.         if (world_layer ~= nil) then

  15.         -- do all Physics() stuff now..

  16.         end

  17. end

  18.  

  19. function end_physics()

  20.         layer_manager.hideLayer("physics_layer")       

  21. end

  22. -- ..

  23.         layout_entry_handler = function()

  24.                 start_physics(some_seed)

  25.         end,

  26.         layout_exit_handler = function()

  27.                 end_physics()

  28.         end

  29.  

Last edited by ibisum on Fri Aug 17, 2012 1:13 am, edited 1 time in total.
;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Thu Aug 16, 2012 11:45 pm

Oh true!

I wasn't getting any errors and everything was building and running fine.

I am working exclusively with xcode and the iphone simulator and my phone, so that may be the cause of the back slashes?

I don't have time until next week to work on this, but thanks so much for the help ibisum, pretty sure that all makes sense and i should be able to get it all working.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby ibisum » Fri Aug 17, 2012 1:10 am

I am working exclusively with xcode and the iphone simulator and my phone, so that may be the cause of the back slashes?


I think its an older version of the moaigui framework, maybe .. you might consider also double-checking that, there are some cute recent fixes/tweaks worth the hassle.

I don't have time until next week to work on this, but thanks so much for the help ibisum, pretty sure that all makes sense and i should be able to get it all working.


I'm going on vacation-mode personally for a week as of tomorrow morning, so it'll be quiet from my front during that time. Hope to see you got it sorted when I get back from the mountains!
;
--
ibisum@gmail.com
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info
User avatar
ibisum
 
Posts: 1024
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: Starting out feedback.

Postby Muzz » Mon Aug 20, 2012 8:30 pm

Ok, got the code all running! Just now i have nothing rendering on screen.... Getting closer.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby Muzz » Mon Aug 20, 2012 11:49 pm

OK progress! I have my game rendering again, but only on pc, the iphone simulator shows nothing and the box2D debug stuff has stopped drawing.

EDIT: what the crap, it runs on iphone as well. its just the simulator that its busted on.

EDIT2: holy wow performance problems as well. This is going to require some work with arcane code i cant read yet... Man learning to code is hard.

I've got some freelance to get done so ill probably look at it tomorrow.

EDIT3: dammit got debug stuff working but it isn't attached to my camera, not the biggest problem as i dont NEED to use the debug stuff but it is a mighty nice working feature. and performance fixed (that happens when you stop making a box 2d world every frame)

EDIT4: Yay fixed the debug stuff. Now i have to get that peski ui drawing.

EDIT5: This must be the most annoying thread. I post thinking i have massive problems and then i fix them 5 minutes later... Still that ui drawing thing is perplexing.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

Re: Starting out feedback.

Postby Muzz » Wed Aug 22, 2012 3:34 am

Got it working! I don't quite know how... Oh well time to break open the whisky.

http://snag.gy/calzy.jpg

... Actually its not quite working on iphone yet, only pc.
Muzz
 
Posts: 88
Joined: Sat May 19, 2012 4:50 pm

PreviousNext

Return to New Users

Who is online

Users browsing this forum: No registered users and 0 guests

cron

x