I'm very confused with a weird behaviour in Cocos2d-x, when I create a CCSprite and a CCMenu with a single CCMenuItem, even thought all of them are positioned at the same location.
mySprite->setPosition(ccp(0,0));
myMenu->setPosition(ccp(0,0));
mySprite is at one place and myMenu with its myMenuItem are at another location, what is happening? and how can I fix this?
Thanks! :'D
In a CCMenu you are not supposed to manually change the position of the items (and their children). Only change the position of the menu itself.
I found the answer, I was using setScale on CCMenu, this messes up the position of every child, you have to use setScale on each CCMenuItem instead of the CCMenu.
Sprite->setPosition(ccp(100,100));
Menu->setPosition(ccp(100,100));
Related
I have a raycast2d node that I want to cast to where the player clicks, but when I click it still casts but not to the right place.
My code is just $RayCast2D.set_cast_to(fire_position), fire_position being where the mouse clicks.
Can anyone help?
The RayCast2D expects a vector on its own local coordinates.
Presumably you got the position of the mouse click in global coordinates. Then you would convert it to the local space of the RayCast2D like this:
$RayCast2D.set_cast_to($RayCast2D.to_local(fire_position))
I'll also remind you that if you are updating raycast and checking it right away, without a physics frame passing, your will have an stale result. To fix that you can call force_raycast_update on it.
It sounds like the issue may be with how you are determining the 'fire_position' variable. Without more information about how that variable is being set, it's difficult to me sayed for certain what the problem is.
However, you can try to debug the issue by printing out the 'fire_position' variable to the console before passing it to the RayCast2D.set_cast_to() method, to check if it's the correct position where the mouse clicked. Also, make sure that you have set the correct orientation of the RayCast2D node, so it is pointing in the direction you want to cast the ray.
What I'm trying to do is to make an "untouchable map". I need to be it kind of a background instead of a real map, and I need to keep it swipeable to left and right fragments. How can I implement that? I've tried to put a layer overlay, but it doesn't work, it's keep focusing on the map when I try to swipe to other fragment. Maybe there is a "switch" for the XML part? Thanks!
map.getUiSettings().setAllGesturesEnabled(false); - this is exactly what I was looking for.
I am new to Android Studio. I am trying to make a basic application that adds two numbers, but each time I move something around, The entire layout gets messed up.
I added a separate View in the center to act as a reference point to counter this, but it is still getting very annoying.
Any idea on how to fix this? I am using Studio version 2.1
If not, is any other way to design the user interface without having to deal with relative layouts?
I have tried linear layouts but those only allow me to place my elements in fixed places which I cannot use in my app.
Please guide me.
Note: I apologize if this question is too simple. I am a newbie after all, do forgive me.
Thanks in advance!
This is indeed the function of RelativeLayout in Android Studio. If you are getting problems with dragging and dropping with RelativeLayout then you should try any other layout. eg. ConstraintLayout
2nd Solution:
Try adding new buttons instead of copying and pasting old ones.
Have you tried using margin: http://android4beginners.com/2013/07/lesson-2-2-how-to-use-margins-and-paddings-in-android-layout/
also look you can align certain object in the xml code relative to eachother, have no link for that atm
I'm absolutely confused.
Studying JavaFX for several months.
In my application I have a custom scrollpane, where I recount scrollbar values manually. Everything is OK there. And when I resize the window it also works fine.
The problem appears when I launch application the first time. I see that my scrollbar value is incorrect, and it become correct when I resize window or move the pane placed inside scrollpane.
So theoretically all i need is just update my scrollpane on window start, or after window start. And... I've spent more than week trying to find out how. And the only way I've managed to do this is to call layoutChildren recursively. This is awful of course.
layout() - doesn't have any effect. I tried it with runLater() and placed it inside timer call. No way!
requestLayout() - also makes no sense.
Is it possible just UPDATE or REDRAW or MARK CONTROL TREE AS DIRTY in JAVAFX ???
Ok well, try this way
first gaining the focus, then try relayout options..
blah.requestFocus();
blah.layout();
Well. layout() works. But it shouldn't be placed inside Platform.runLater().
In simple example everything is fine. Then I suggest I have something wrong with my controls.
Thanks.
I need help for, scribbling on the webpage i.e where ever the user moves on the uiwebview there it should draw a line according to the touch moves.
Is this possible.
Can any one please help me in this.
Thanks,
Mrudula.
yes it is possible just you have to write uiWebView.scrollView instead of uiWebView for getting coordinates of uiwebview.
I started working on something sort of like this. It doesn't currently let you "draw", but it does let you detect and record relative touch coordinates so that you can scale them correctly when zooming in. The DSAnnotationView object lets you provide a custom UIView to be toggled at the annotation point. Check it out here: https://github.com/justindarc/WebViewAnnotations
-Justin