Stencyl 3.4.0 is now out. Get it now!

[ALPHA] Positioning Utils 1.1

yoplalala

  • *
  • Posts: 1412
Here's is my positioning utils .

I've renamed all the block tags, so that they won't collide with the scale extension utility on which it was loosely based not so long ago. The proble is that for those who downloaded the version at http://community.stencyl.com/index.php/topic,46621.msg260348.html#new , it won't be totally compatible so you can download the in between version , look for the blocks with TODEL  in the behaviours and exchange them with the good version.
Manual In Progress ...

getScale : get scale percentage for actor     ( same as in scale extension)
scaledCoord  get scaled coord  ( different than scale extension    there's x-left,x-middle,x-right, y-top y-middle y-bottom  on the scene / on the screen)
offset : coordinates for scaled points  ( same as scale version)
scale:  Scale in percentage  ( same as scale version)
setScale: Scale in pixel,  ( different than scale extension  keeping ratios or not
scaledSize : in pixels ( same as scale version)
isScaled:  ( same as scale version)

+++ added blocks
setScaledCoord
setRealSize: Set real size (not scaled size) useful when actor is attached to image instance  ( not tested with collisions, shouldn't work)
setHeightAndWidth :  Grow size depending on point   ( made to bypass the grow system which doesn't work when actor is set to not move)

fitActorInRectangle:  change actor's size so that it fits into a rectangle. If can grow, it will be able to grow the actor ( SHOULDN'T WORK YET )
 

getOriginPointActor :  current origin point for actor
setOriginPointActor :  set current origin point for actor. After the tween block, you have to set it the old one because of bugs with collisions
setXActor  :  scaled/non scaled   x-left, x-right, x-middle  from bottom/middle/top of screen    ( in the future,  scene and camera too)
setYActor  :  scaled/non scaled   y-top, y_middle, y_left  from bottom/middle/top of screen    ( in the future,  scene and camera too)
xForActor same as set x actor except that it doesn't set it but just returns the theorical value , useful in the slide tween
yForActor  same as setY actor except that it doesn't set it but just returns the theorical value , useful in the slide tween
getSizeActorType  get size for default animation for actor type

setXActorFromActor  set x middle, x-left , xright depending of another actor x middle x right x left
setYActorFromActor
destroyActor : destory actor, doesn't recycle it,  must be used with  actors created with  createActorFromImgInst  or which has use setRealSize
createActorFromImgInst:  create actor from img inst   ( not tested with collisions, shouldn't work),   great for labels ! ( should also work with stencyl's version of labels, I use my own version)
isActorInsideActor : returns percentage of  actor inside bigger actor for non rotated actors

All suggestions are welcomed :)

LIBERADO

  • *
  • Posts: 2421
Thank you so much! This is a superb extension.



Downloaded and installed. I will test it.  :)

« Last Edit: March 14, 2016, 01:12:29 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

LIBERADO

  • *
  • Posts: 2421
Really, this great extension easily solves important issues.
For example: http://community.stencyl.com/index.php/topic,48740.0.html

The more I use this extension, the more I am surprised at how much powerful and useful it is.
I can not stop using it. This is one of the best extensions I have ever seen.

Thank you very much, yoplalala.

« Last Edit: August 12, 2016, 11:12:36 pm by LIBERADO »
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

BMJ

  • *
  • Posts: 273
OH WOW this is incredible ... thank you yoplalala! So many uses ... (!) This has opened up a lot of really nice platformer game mechanics that would have otherwise been a major headache, if they were even possible before at all.

Thanks again. :D (Do you have a donation button somewhere?)

« Last Edit: August 13, 2016, 01:15:23 pm by BMJ »

Rainbros

  • *
  • Posts: 173
Great extension, but I can't quite seem to figure this out. What's the easiest way to exactly align (center) two actors using these blocks, regardless of their scaling? The wording of the blocks is not very clear. What do "real x/y" and "true x/y" refer to? And what do the exclamation marks and arrows mean?

yoplalala

  • *
  • Posts: 1412
Hi !

Exclamation  marks and arrows don't work everywhere it seems.  But it's there to indicate the directions.
-> From left to right   <- from right to left
!  From bottom to top

Put real for regardless of their scaling.
For "real" and "true" , I used the terms used in the engine, but they're not very clear.
If you have som improvements for the wording tell me ;)

"scaled takes in account the scaling, so that's the one I always use :)
true takes no account of scaling.

So better to use "scaled". I've put the option "true" in case it coulb useful, but I never had to use it ...


real x means the x of the actor ( the real or true x of the actor not the scaled x) 
"real x for scaled x-middle actor to 0  from middle of the screen"
which will be the x that the should have if his middle were in the middle of the screen.

this block is useful if you want to put it in slide blocks for example
you have you scaled actor somewhere on the screen , you want to go the middle of the scrren
so you slide actor  to the "real x for scaled x-middle actor to 0  from middle of the screen"


To align the center of  an actor to an  another actor2, simply
you set scaled actor y-middle to  0 from the scaled x middle of the actor2 -->

I love to use this block to set align the bottoms ...

Hope to have answered all your questions.

Thanks Liberado and BMJ :). Don't forget if you have suggestions for improvements, or  bugs, tell me :)  As it didn't seem popular at first, kind of left it here, I think I have an imprved version with maybe one or two bugs corrected. I should check it again to see which were the bugs before uploading it .


designpeg

  • *
  • Posts: 507
Hi, great extension! I'd like to use the 'create actor from img inst' block, but when I do, the actor it creates doesn't seem to be effected by actor effects  - like tint, change hue etc. in the same way as an ordinary actor is. do you know how I can fix this difference?

yoplalala

  • *
  • Posts: 1412
Hi ! The create actor from img instance uses the image instance sot it has the same problems of as image instances have.
Like you do there http://community.stencyl.com/index.php/topic,50000.0.html
I don't know how you can do :( . I wasn't able to make the exact same effects as "tint", etc for image instances. 
what effects do you want to use ?
Hopefully someone the stencyl team will answer to you thread,.
I wanted to explore how to directly change the spritesheet of the actor, as the system will change in openfl 4 , I wasn't too keen on it.

designpeg

  • *
  • Posts: 507
Hi yoplalala, thanks for your quick reply - it's really frustrating that tint works on flash but not images instances, hopefully the stencyl team will correct it at some point. I've found a post that describes how you can alter an actors sprite sheet at runtime:

 http://community.stencyl.com/index.php/topic,20203.msg117951.html#msg117951

i'm just struggling to get it to work.

rob1221

  • *
  • Posts: 9048
I wanted to explore how to directly change the spritesheet of the actor, as the system will change in openfl 4 , I wasn't too keen on it.
If you look at filters in Actor.hx this is how it is done for mobile and desktop for most filters.


designpeg

  • *
  • Posts: 507
Hi, i'm struggling, any chance you could give a clue on how to convert this from NME to openfl?

_actor.animationMap.get(/* animation name*/).tilesheet.nmeBitmap.copyPixels(/* bitmap data to overlay */, new nme.geom.Rectangle(0,0,10,10) /*this determines the rectangular portion of the data to transfer over*/, new nme.geom.Point(0,0) /*this determines the position of the rectangles upper left corner within the base image*/, null, null, true);

rob1221

  • *
  • Posts: 9048
Use getBitmap() in place of nmeBitmap and replace nme with openfl.

designpeg

  • *
  • Posts: 507
Hi Rob1221, thanks for the help, I've made the changes but still get a  'a term is undefined and has no properties" error

the original poster said he had to edit SheetAnimation.hx to make tilesheet a public variable and 2) edit Actor.hx to change animationMap from Hash<DisplayObject> to Hash<Dynamic>.

could you explain what he meant by this? I've had a look at the two files, but can't see anything like this or is the original post out of date now for the latest version of stencyl?

rob1221

  • *
  • Posts: 9048
"_actor" would refer to an attribute called "actor".  Change that to whatever attribute you're using.  For more up to date code refer to Actor.hx.