How to get Button position and size after "setRotation3D" in cocos2dx 3.3 - cocos2d-x-3.0

i have a button in the panel(cocos2dx 3.3), and call the methond "button->setRotation3D(Vec3(30, 0, 0))".But now i don't know how to get button's(and it's children) right position and contentSize on the screen after "transform".Anyone knows? Thanks.

can you added your sptite in nodegird than
like that
auto node= NodeGrid::create();
this->addChild(node);
auto sp = Sprite::create("HelloWorld.png");
sp->setPosition(100,330);
node->addChild(sp);
node->setRotation3D(Vec3(10,110,11));

Related

Unity - How to scroll a scrollbar for a ScrollRect smoothly?

I have a ScrollRect to which I add content to. When it reaches the point where the content is longer than the ScrollRect (ie when the ScrollBar's value changes from 0), I want the ScrollRect to scroll all the way down (I do this by tweening the ScrollBar's value until it reaches 0). However, my problem is that I can't figure out how to do this smoothly over time.
Here's my code snippet:
public void Update() {
if (scrollbar.size < 1 || scrollbar.value > 0) {
LeanTween.value(scrollbar.value, 0, duration).setOnUpdate((float val) => {
if (scrollbar.value == 0) {
LeanTween.cancel(this.gameObject);
} else {
scrollbar.value = val / scrollAdjustment;
}
});
}
}
I tried using "Time.deltaTime" and "Time.time" in place of duration and it did not seem to matter. Here's a gif of what happens:
(In this example, I used "duration" that had the value of 5 (the idea was to have the transition take 5 seconds) and "scrollAdjustment" was 50 but it did not seem to matter what I set either of these values to.
You can see it instantly snaps to the bottom. I'd like this to be a smooth transition. Any help is appreciated!
My settings:
Then here is me scrolling with my mouse wheel while the autoscroll feature is turned off (because I'm using Rewired, I am intercepting an input called "ZoomIn" and "ZoomOut" and add "0.01f * scrollSpeed" (where scrollSpeed is 15 in this case):
You shouldn't need to add any additional code to make the scroll bar function as the way you want it to. Try deactivating your script and mess with your scroll bar. Make sure you have your Number Of Steps On Your Scrollbar Component as 0 to make it smooth. If it's still not working, send some screenshots of your scroll gameobject to see if the rect is the problem or something else.

How to slide a panel from right to left using bunifuTransition in c#

I have bunifutransition1 that slides my mainpanel from left to right upon clicking showbutton. (It shows the hidden mainpanel.)
What I want is, when I click closebutton, the mainpanel will slide from right to left (to hide the mainpanel again). It seems that bunifuTransition does not have an animation that reverses the animation of VertSlide or HorizSlide.
What should I do to slide my mainpanel from right to left to hide it again on my form?
I was having the exact same issue but upon reading your question the answer finally became prevalent in my mind. The solution here is to stop using BunifuTranisition altogether and go for the good ol' for loops and the other mods, puns intended.
int originalWidth = panel.width;
int menuClicksIndex = 0;
private void beginTransition()
{
if (menuClickIndex % 2 == 0)
{
//This executes on the first click
for(int i = originalWidth-1; i>=0; i--)
{
// Loops from original width to 0
panel.Width = i;
}
}
else
{
for (int i = 0; i <= originalWidth; i++)
{
panel.Width = i;
}
}
menuClickIndex++;
}
This works for me but it glitches on the way back from left to right. So a mixed version with BunifuTransitions for the opener and the for loop for the closer would be the ideal solution here.
UPDATE 1: It seems as if while changing the width of the panel from 0 to say, 350, the content inside the panel doesn't render until the height is set to the max, but while decreasing the height from 350 to 0, the content is already rendered and so it seems smooth to close but cluttery to open, hence probably explaining why BunifuTransition is unable to do that as well.
Solution Here.
Just go bunifu transition properties
Open or dragdown DefaultAnimation. Find this option in menu ("Side Coeff") It Show value of
X and Y {X=1, Y=0} . You just change this value {X=-1, Y=0}.
Then Start your project and check. Your slider sliding left to right. :)
Keep enjoy.
Regards,
Haris Ali
Use this command: bunifuTransition1.HideSync(guna2Panel1); before any code on event button click!

Unity 5: how to zoom and translate an object from a grid layout to the center of the screen

I'm trying to create a scroll grid view in which every cell object is tapable.
When a cell object is tapped I want to scale and traslate it to the center of the screen and render it above other cells.
I was able to make it tapable and scale it in its position. Now I want to move the cell object to the center of the screen and render it above other cells.
I've tried many solutions but none of them works.
This is my hierarchy:
This is the grid in normal state:
This is the grid when a cell was tapped:
I'm populating the grid from a C# script dynamically.
void Populate()
{
GameObject cardContainerInstance, cardInstance;
foreach (var c in cardsCollection.GetAll())
{
if (c.IsOwned)
{
cardContainerInstance = Instantiate(cardContainer, transform);
cardInstance = cardContainerInstance.transform.Find("Card").gameObject;
var cardManager = cardInstance.GetComponent<CardManager>();
cardManager.card = c;
cardManager.AddListener(this);
}
else
{
Instantiate(cardSlot, transform);
}
}
}
public void OnCardClick(GameObject cardObject, Card card)
{
Debug.Log("OnCardClick " + card.name);
if (openedCard != null) {
if (openedCard.Number == card.Number)
{
CloseCard(openedCardObject);
}
else
{
CloseCard(openedCardObject);
OpenCard(cardObject, card);
}
}
else
{
OpenCard(cardObject, card);
}
}
void OpenCard(GameObject cardObject, Card card)
{
//cardObject.GetComponent<Canvas>().sortingOrder = 1;
var animator = cardObject.GetComponent<Animator>();
animator.SetTrigger("Open");
openedCard = card;
openedCardObject = cardObject;
}
void CloseCard(GameObject cardObject)
{
var animator = cardObject.GetComponent<Animator>();
animator.SetTrigger("Close");
openedCard = null;
openedCardObject = null;
}
I can't figure out how to move the cell to the center and render it above others.
Note that all is animated using an animator attached to the object itself.
Could anyone help me please? Thank you very much!
EDIT: more details
All cell object have the following hierarchy:
where:
CardContainer is an empty object added to use animator on Card child object
Card is the object itself that has a script, a canvas renderer and an animator
StatsImage is the object that slide out when the card is tapped
Image is a calssic UIImage with Image script, Shadow script and canvas renderer
Other component are simple texts.
EDIT: fix in progress
Trying to apply this suggestions I was able to manage the rendering order (as you see on the image below) but it seems that prevent touch events to be detected on the game object.
I've added a GraphicsRaycaster too and now the bottom horizontal scroll view scrolls again but only if I click and drag a card.
Moreover, with the GraphicsRaycaster, the main grid card still are not clickable and it's possible to open the card only if it is behind the bottom panel (if I click on the red spot in the image below the card behind the panel receives che click)
This is the CardContainer at runtime(note that I'm attaching new Canvas and GraphicsRaycaster on the CardContainer, which is the "root" element):
You didn't clarify whether you are using a sprite renderer or some other method but here is an answer for each.
Sprite renderer:
this the simple one. In each sprite renderer, there is a variable called "sortingOrder" in script and "Order in layer" in the inspector. sprite renderer with sorting Orders that are higher is rendered first. All you would need to do is call:
cardObject.GetComponent<SpriteRenderer>().sortingOrder = 1;
when you click the card, and
cardObject.GetComponent<SpriteRenderer>().sortingOrder = 0;
when you unclick it. I hope that makes sense!
Other Method:
this one is a bit harder and I would suggest that you switch to sprite renderers and it will be much easier and more stable down the road, but I can understand if you have already written a lot of scripts and don't want to go back and change them.
Anyway, all you will need to do Is create two layers: cardLower and cardUpper. then create a new camera and call it topCamera. now under the top camera object in the inspector, change the culling mask (it's near the top) and make sure cardUpper is selected. then change the Clear flags (first one) to "Don't Clear" finally change the depth to 0 (if that doesn't work change it to -2). Now objects in the cardUpper will always be rendered above everything else. You can change the layer through script with
cardObject.layer = "cardUpper"
or
cardObject.layer = "cardLower"
I hope that helps!
Ok, so its pretty simple. So you are going to want to add another canvas component to the game object, and check the override sorting to true. Then use
cardObject.GetComponent<Canvas>().sortingOrder = 1;
to place it in the front and
cardObject.GetComponent<Canvas>().sortingOrder = 0;
to put it in the back.
you are also going to need to put a GraphicsRaycaster on to each of the cardObjects
Ignore my other answer about sprite renderers, they are not needed here

How to remove a view from layout in RCP

I have an application where I have different perspective.In one perspective I want to remove certain views which has been added to the layout.
Below is my snippet:
This is the snippet which I call when I want to reset perspective
public void createInitialLayout(IPageLayout layout) {
layout.setEditorAreaVisible(false);
layout.setFixed(false);
//I am dividing the whole layout into 4 parts.One is top left,top right,bottom left,bottom right.
IFolderLayout topLeft = layout.createFolder(TOP_LEFT_ID, IPageLayout.LEFT, 0.25f, IPageLayout.ID_EDITOR_AREA);
topLeft.addView(SpaceView.ID);
topLeft.addView(RepositoryView.ID);
IFolderLayout topRight = layout.createFolder(TOP_RIGHT_ID, IPageLayout.TOP, 0.25f, IPageLayout.ID_EDITOR_AREA);
topRight.addView(ModuleView.ID);
topRight.addView(ProjectChangeLogView.ID);
topRight.addView(SearchViewPart.ID);
IFolderLayout bottomLeft = layout.createFolder(BOTTOM_LEFT_ID, IPageLayout.BOTTOM, 0.70f, TOP_LEFT_ID);
bottomLeft.addView(QueueView.ID);
IFolderLayout bottomRight = layout.createFolder(BOTTOM_RIGHT_ID, IPageLayout.BOTTOM, 0.55f, TOP_RIGHT_ID);
bottomRight.addView(Objects.ID);
}
Now after the perspective got reset ,I want to remove certain views (e.g Object view) from the layout.Here I dont get any option for bottomRight.delelte/removeView etc.So how can I achieve the same?
The perspective factory is only used when the perspective is first used and when it is reset. It can't be used to change the layout of an open perspective.
I don't know of a simple way to move the position of views. You probably need to modify the e4 application model by moving the MPart to a new MPartStack in a similar way to the drag and drop code (org.eclipse.e4.ui.workbench.addons.dndaddon.DnDManager)

Can I use icons with RGBA transparency when using GTK+ drag and drop?

I am in the process of adding drag and drop support to an existing Mono/C#/GTK# application. I was wondering whether it was possible to use RGBA transparency on the icons that appear under the mouse pointer when I start dragging an object.
So far, I realized the following:
I can set the bitmap in question by calling the Gtk.Drag.SourceSetIconPixbuf() method. However, no luck with alpha transparency: pixels that are not fully opaque would get 100% transparent this way.
I also tried calling RenderPixmapAndMask() on the GdkPixbuf so that I could use Gtk.Drag.SourceSetIcon() with an RGBA colormap of my Screen. It didn't work either: whenever I started dragging, I got the following error:
[Gdk] IA__gdk_window_set_back_pixmap: assertion 'pixmap == NULL || gdk_drawable_get_depth (window) == gdk_drawable_get_depth (pixmap)' failed.
This way, the pixmap doesn't even get copied, only a white shape (presumably set by the mask argument of SetSourceIcon()) shows up on dragging.
I'd like to ask if there's a way to make these icons have alpha transparency, despite the fact that I failed to do so. In case it's impossible, answers discussing the reasons of the lack of this feature would also be helpful. Thank you.
(Compositing is - of course - enabled on my desktop (Ubuntu/10.10, Compiz/0.8.6-0ubuntu9).)
Ok, finally I solved it. You should create a new Gtk.Window of POPUP type, set its Colormap to your screen's RGBA colormap, have the background erased by Cairo to a transparent color, draw whatever you'd like on it and finally pass it on to Gtk.Drag.SetIconWidget().
Sample code (presumably you'll want to use this inside OnDragBegin, or at a point where you have a valid drag context to be passed to SetIconWidget()):
Gtk.Window window = new Gtk.Window (Gtk.WindowType.Popup);
window.Colormap = window.Screen.RgbaColormap;
window.AppPaintable = true;
window.Decorated = false;
window.Resize (/* specify width, height */);
/* The cairo context can only be created when the window is being drawn by the
* window manager, so wrap drawing code into an ExposeEvent delegate. */
window.ExposeEvent += delegate {
Context ctx = Gdk.CairoHelper.Create (window.GdkWindow);
/* Erase the background */
ctx.SetSourceRGBA (0, 0, 0, 0);
ctx.Operator = Operator.Source;
ctx.Paint ();
/* Draw whatever you'd like to here, and then clean up by calling
Dispose() on the context's target. */
(ctx.Target as IDisposable).Dispose ();
};
Gtk.Drag.SetIconWidget(drag_context, window, 10, 10);