[contrib] Capability to track a transform with a camfit

Organize and discuss new features you're working on, and community requests.

Moderators: seebs, ezraanderson, Vavius

[contrib] Capability to track a transform with a camfit

Postby monomon » Sat May 28, 2016 7:17 pm

Hi, I added the capability to track any MOAITransform using a MOAICameraFitter2D.
repo is here
https://github.com/monomon/moai-dev
and this the commit
https://github.com/monomon/moai-dev/com ... b371fda328
also includes a (bad) example

You use it like this:
Code: Select all
  1. camfit = MOAICameraFitter2D.new()

  2. prop = MOAIProp.new()

  3. camfit:startTrackingNode(prop)

  4. -- ...

  5. camfit:stopTrackingNode()



I'd like to ask the devs on which branch they prefer pull requests.
This is my first contribution, so critique would be great.
monomon
 
Posts: 4
Joined: Sat May 28, 2016 6:51 pm

Re: [contrib] Capability to track a transform with a camfit

Postby halfnelson » Sun May 29, 2016 6:58 pm

nice work. Out of interest, what does this give you that MOAICameraAnchor2d doesn't? http://moaiforge.com/samples/sample-browser/player/index.html#camera-fitter

It is certainly less verbose, are there any other advantages?
halfnelson
 
Posts: 710
Joined: Wed Jun 13, 2012 9:48 pm

Re: [contrib] Capability to track a transform with a camfit

Postby monomon » Mon May 30, 2016 11:29 am

The intended usage is different.

If you have multiple anchors, the camfit will fit all of them on the screen (e.g. by zooming out).
If an anchor happens to be at the edge of the viewport and moves, the camfit will still try to keep that anchor at the edge of the view.

Tracking, on the other hand, keeps the passed (single) prop centered, by setting the fit location of the fitter.

Perhaps it is possible to use a single anchor on the screen to achieve this, but I was unable to get it to work.
Part of the problem was that setting an anchor's rect did not seem to do anything. I wanted to have some padding around units so they could see at least a few neighboring cells on the map when at the viewport edge:
Code: Select all
  1. // prop is 64x64

  2. unitProp = MOAIProp2D.new()

  3. anchor:setParent(unitProp)

  4. anchor:setRect(-128, -128, 128, 128)



However, the prop would reach the viewport edge and the anchor's rect would not cause the viewport to move to respect the 'padding'. That would have been sufficient for me, although keeping the unit centered works better for my use case.
monomon
 
Posts: 4
Joined: Sat May 28, 2016 6:51 pm

Re: [contrib] Capability to track a transform with a camfit

Postby ibisum » Wed Jun 01, 2016 8:11 am

Very nice work, I'd like to use this immediately .. ;)

I'd like to ask the devs on which branch they prefer pull requests.


Any PR that gets done on -develop branch on this repo:

https://github.com/moai/moai-dev

.. should be a safe bet. I will test anything you submit, personally, because this is a great feature ..

(But it should be noted, I guess, that the 'official' release of the MOAI SDK is https://github.com/moaiforge/moai-sdk/, but anyway I think merging from -develop is an old habit of the current maintainer of the SDK releases, anyhoo, ... at least this way, public PR's on moai-dev can be easily propagated elsewhere ..
;
--
Email: ibisum@gmail.com
IRC: torpor on FreeNode, see you in the #moai channel
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info/
User avatar
ibisum
 
Posts: 1504
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria

Re: [contrib] Capability to track a transform with a camfit

Postby halfnelson » Wed Jun 01, 2016 7:20 pm

Definitely moai-dev for PR's moaiforge/moai-sdk is gone
halfnelson
 
Posts: 710
Joined: Wed Jun 13, 2012 9:48 pm

Re: [contrib] Capability to track a transform with a camfit

Postby ibisum » Thu Jun 02, 2016 2:05 am

Definitely moai-dev for PR's moaiforge/moai-sdk is gone


Roger that, sir!
;
--
Email: ibisum@gmail.com
IRC: torpor on FreeNode, see you in the #moai channel
Got a MOAI snippet? Please consider adding it to http://moaisnippets.info/
User avatar
ibisum
 
Posts: 1504
Joined: Mon Oct 17, 2011 1:11 am
Location: Vienna, Austria


Return to Community Contributions

Who is online

Users browsing this forum: No registered users and 1 guest

cron

x