Rotate on startDrag () function
how can I make an MC rotate when I use the on (press) with
the this.startDrag() function? I have tried many different ways of
doing this, but all that happens is... nothing at all. I've tried
fitting in the _rotation and the rotate command, but all fails.
Please help me. Thanks in advanced.
"DJ Sick Nick" <[email protected]> wrote in
message
news:eevc0h$ldm$[email protected]..
> how can I make an MC rotate when I use the on (press)
with the
> this.startDrag()
> function? I have tried many different ways of doing
this, but all that
> happens
> is... nothing at all. I've tried fitting in the
_rotation and the rotate
> command, but all fails. Please help me. Thanks in
advanced.
>
assuming the instance name of your draggable mc is "drag_me"
you could do:
drag_me.onPress = function() {
this.startDrag(false);
//Not necessary, but may give you some values to help with
rotation
below.
// These are just the values of the cursor when you first
press the
button.
var startX:Number = _root._xmouse;
var startY:Number = _root._ymouse;
this.onMouseMove = function() {
//Again, not necessary, but now you can compare the values
of the
start and current every frame.
var currentX:Number = _root._xmouse;
var currentY:Number = _root._ymouse;
//maybe use the differences between currentX and startX (and
Ys) to
do some rotation.
this._rotation = ..... ? ......
drag_me.onRelease = function() {
stopDrag();
this.onMouseMove = undefined;
or, if you just want it to start rotating, regardless of
position, you could
try:
drag_me.onPress = function() {
this.startDrag(false);
this.onEnterFrame = function() {
this._rotation += 1;
drag_me.onPress = function() {
stopDrag();
delete this.onEnterFrame;
Please note, no code above has been tested.
SMB
Similar Messages
-
My iphone 4 photo/message auto rotation was not functioning, might be accidentally locked as I can see a locked symbol with a circle with an arroe surrounding it at the top right angle , next to the power % indicator. This function was working perfectly since day 1.
Please advise how to unlock it.Swipe upwards from the bottom of the screen to open Control Center. You will then find the orientation lock in the top row, last icon on the right. White is on, black is off. Tap and turn it off. If you see the lock symbol, then orientation lock is on, and that is what is keeping it in the portrait mode.
-
Can not get the index number from a StartDrag Function
var t:Array=new Array();
t=[d1,d2,d3,d4,d5];
var d:Array=new Array();
d=[t1,t2,t3,t4,t5];
var ust:int;
for(var i:int=0;i<t.length;i++){
t[i].addEventListener(MouseEvent.MOUSE_DOWN, mouseDowner);
for(var j:int=0;j<t.length;j++){
t[j].addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
function mouseDowner(event:MouseEvent):void {
event.target.startDrag();
trace(t.indexOf(MovieClip(event.target)));
var ast:int;
ast=t.indexOf(MovieClip(event.target));
trace(ast);
ust=ast.valueOf();
function mouseReleased(event:MouseEvent):void {
event.target.stopDrag();
if(d.indexOf(MovieClip(event.target).dropTarget.parent)!=-1){
trace(d.indexOf(MovieClip(event.target).dropTarget.parent));}
else{trace("not appropriate");}
//trace(MovieClip(event.target).dropTarget.parent.name);
var tf1:TextField = new TextField();
tf1.text="LIGHT";
tf1.x=-30;
tf1.y=-30;
t1.addChild(tf1);
tf1.mouseEnabled=false;
var tf2:TextField = new TextField();
tf2.text="EASY";
tf2.x=-30;
tf2.y=-30;
t2.addChild(tf2);
tf2.mouseEnabled=false;
var tf3:TextField = new TextField();
tf3.text="IMPOSSIBLE";
tf3.x=-30;
tf3.y=-30;
t3.addChild(tf3);
tf3.mouseEnabled=false;
var tf4:TextField = new TextField();
tf4.text="FAST";
tf4.x=-30;
tf4.y=-30;
t4.addChild(tf4);
tf4.mouseEnabled=false;
var tf5:TextField = new TextField();
tf5.text="UGLY";
tf5.x=-30;
tf5.y=-30;
t5.addChild(tf5);
tf5.mouseEnabled=false;
var tf6:TextField = new TextField();
tf6.text="DARK";
tf6.x=-30;
tf6.y=-30;
d1.addChild(tf6);
tf6.mouseEnabled=false;
var tf7:TextField = new TextField();
tf7.text="DIFFICULT";
tf7.x=-30;
tf7.y=-30;
d2.addChild(tf7);
tf7.mouseEnabled=false;
var tf8:TextField = new TextField();
tf8.text="POSSIBLE";
tf8.x=-30;
tf8.y=-30;
d3.addChild(tf8);
tf8.mouseEnabled=false;
var tf9:TextField = new TextField();
tf9.text="SLOW";
tf9.x=-30;
tf9.y=-30;
d4.addChild(tf9);
tf9.mouseEnabled=false;
setChildIndex(d5, 1);
var tfh:TextField = new TextField();
tfh.text="BEAUTIFULL";
tfh.x=-30;
tfh.y=-30;
d5.addChild(tfh);
tfh.mouseEnabled=false;
setChildIndex(d[0], 0);
setChildIndex(d[1], 0);
setChildIndex(d[2], 0);
setChildIndex(d[3], 0);
setChildIndex(d[4], 0);
trace(ust);var t:Array=new Array();
t=[d1,d2,d3,d4,d5];
var d:Array=new Array();
d=[t1,t2,t3,t4,t5];
var ust:int;
var alt:int;
for(var i:int=0;i<t.length;i++){
t[i].addEventListener(MouseEvent.MOUSE_DOWN, mouseDowner);
for(var j:int=0;j<t.length;j++){
t[j].addEventListener(MouseEvent.MOUSE_UP, mouseReleased);
function mouseDowner(event:MouseEvent):void {
event.target.startDrag();
trace(t.indexOf(MovieClip(event.currentTarget)));
ust=t.indexOf(MovieClip(event.currentTarget));
trace(ust);
trace(ust);
function mouseReleased(event:MouseEvent):void {
event.target.stopDrag();
if(d.indexOf(MovieClip(event.currentTarget).dropTarget.parent)!=-1){
trace(d.indexOf(MovieClip(event.currentTarget).dropTarget.parent));
alt=d.indexOf(MovieClip(event.currentTarget).dropTarget.parent);
trace(alt);}
trace(alt);
trace(ust);
if(alt==ust){trace("ok");}
else{trace("not appropriate");}
var tf1:TextField = new TextField();
tf1.text="LIGHT";
tf1.x=-30;
tf1.y=-30;
t1.addChild(tf1);
tf1.mouseEnabled=false;
var tf2:TextField = new TextField();
tf2.text="EASY";
tf2.x=-30;
tf2.y=-30;
t2.addChild(tf2);
tf2.mouseEnabled=false;
var tf3:TextField = new TextField();
tf3.text="IMPOSSIBLE";
tf3.x=-30;
tf3.y=-30;
t3.addChild(tf3);
tf3.mouseEnabled=false;
var tf4:TextField = new TextField();
tf4.text="FAST";
tf4.x=-30;
tf4.y=-30;
t4.addChild(tf4);
tf4.mouseEnabled=false;
var tf5:TextField = new TextField();
tf5.text="UGLY";
tf5.x=-30;
tf5.y=-30;
t5.addChild(tf5);
tf5.mouseEnabled=false;
var tf6:TextField = new TextField();
tf6.text="DARK";
tf6.x=-30;
tf6.y=-30;
d1.addChild(tf6);
tf6.mouseEnabled=false;
var tf7:TextField = new TextField();
tf7.text="DIFFICULT";
tf7.x=-30;
tf7.y=-30;
d2.addChild(tf7);
tf7.mouseEnabled=false;
var tf8:TextField = new TextField();
tf8.text="POSSIBLE";
tf8.x=-30;
tf8.y=-30;
d3.addChild(tf8);
tf8.mouseEnabled=false;
var tf9:TextField = new TextField();
tf9.text="SLOW";
tf9.x=-30;
tf9.y=-30;
d4.addChild(tf9);
tf9.mouseEnabled=false;
setChildIndex(d5, 1);
var tfh:TextField = new TextField();
tfh.text="BEAUTIFULL";
tfh.x=-30;
tfh.y=-30;
d5.addChild(tfh);
tfh.mouseEnabled=false;
setChildIndex(d[0], 0);
setChildIndex(d[1], 0);
setChildIndex(d[2], 0);
setChildIndex(d[3], 0);
setChildIndex(d[4], 0); -
My iPad can't rotate anymore.Switch not lock,any idea?
Is there a lock symbol at the top of the screen next to the battery indicator ? If so, then depending on what you've got Settings > General > Use Side Switch To set to (rotation lock or mute notifications), then you can lock/unlock the rotation by the switch on the right hand side of the iPad, or via the taskbar : double-click the home button; slide from the left; and it's the icon far left; press home again to exit the taskbar. The function that isn't on the side switch is set via the taskbar instead : http://support.apple.com/kb/HT4085
If there isn't a lock symbol then try a reset : press and hold both the sleep and home buttons for about 10 to 15 seconds (ignore the red slider), after which the Apple logo should appear - you won't lose any content, it's the iPad equivalent of a reboot. -
S6000 3g auto rotation not function. Bios china language
Hello in the round,
I need help with my Lenovo S6000 3g. The auto rotation does not function, even though it is switched on in the android program.
I have done hard reset by mistake the wrong, and am unfortunately landed in the bios where everything is in china language.
When you go out again I have apparently adjusted the sensors.
Now the auto rotation is no longer
Can someone give me a tip on how I again.
Thanks for the help.
ManfredYou can try one simple solution, this may work or may not, but on many of the devices, it worked. Remove the sim card and turn on your tab. Now, it (auto rotation) should work. You can then after again insert the sim.
You can say thank you by pressing the star left to my post IF I HELPED YOU -
Working with images - Rotation and Movement
Hello there,
I have this problem that I cant seem to solve:
I need to be able to move an image arround and there are restrictions to where image should be able to move: at any given time, when dragging, image should always cover whole body of a given border_container, this is simply achieved by sending a rectangle to the startDrag function, which will specify where the image is allowed to move. I got that part right, and its working, the problem arrise when I try to rotate the border_container (with the image), it should still be only possible to drag image so it all the time covers the body of the border_container, but I don't know how to do it.
Code I use looks something like this:
image.startDrag(getImageDragRectangle());
protected function getImageDragRectangle():Rectangle
return new Rectangle(
this.width-image.contentWidth + x,
this.height-image.contentHeight + y,
Math.abs(this.width-image.contentWidth),
Math.abs(this.height-image.contentHeight));
Edit: image is not inside the border_container (not sure how relevant it is..)
Could anyone help me out here and give me any hints or suggestions how I could fix it?You would have to write the image to a temporary file so that the browser could read it off the server. Browsers do not have access to the database, so there's no way to get the image from the database to the browser without using some sort of interim solution.
~Jer -
How do I create rotating news stories on a web page?
I need to create rotating news stories on a Home page -- where there is an image with text that users can click to access the story they want to read. I have been using Dreamweaver MX for years and was forced to switch to Dreamweaver CS4 when I started a new job. I am NOT a developer and am having a hard time getting used to CS4 - which is designed (in my humble opinion) for developers. Can you create rotating news stories functionality in MX? A link to a tutorial would help. Or a book that gives very straightforward, step by step instructions using MX (preferred) or CS4.
Thank so much for any light you can shed on this, for me, perplexing topic.
All the best,
CarolynSimple method: Put your news items on seperate pages. Add links from parent page to the respective article pages.
MX is too old to support Spry widgets, but CS4 does.
Look at Spry Data Sets:
http://labs.adobe.com/technologies/spry/samples/
Nancy O.
Alt-Web Design & Publishing
Web | Graphics | Print | Media Specialists
http://alt-web.com/
http://twitter.com/altweb -
Auto rotation is not working properly with iOS 7.1.2 upgrade
I recently upgraded my iPad to iOS 7.1.2 and noticed that auto rotation isn't functioning properly. How will this problem fix, will I have to wait till the next update ??
It takes too much time, or doesn't happen at all.
I have an iPad mini with retina display, 128GB storage.
Thanking you in anticipation .Try a reset and see if it fixes the problem. You will not lose any data.
Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider if it appears on the screen - let go of the buttons. Let the iPad start up. -
I'm using Javascript to rotate background images -->
function rotateImages() {
setInterval("startRotator()", 7000);
var counter = 0;
function startRotator() {
var images = ["images/finance1.jpg","images/finance2.jpg","images/finance3.jpg","images/finance4.jpg","images/finance5.jpg","images/finance6.jpg"];
if( counter >= images.length ) {
counter = 0;
var image = "url('" + images[counter] + "')";
counter++;
document.body.style.backgroundImage=image;
The script is triggered by the load event when the homepage loads and the script only runs on the homepage. Everything works fine upon opening the homepage.
If I leave the home page and return, the images will have trouble loading for about 3 to 5 cycles and I'll get white backgrounds for part of the time. The same thing happens if I enter the site from a page other than the homepage and then go to the homepage.
I discovered, however, that if I enter the site at the homepage and then leave the homepage and return using the back button, everything runs fine. Apparently it then accesses a cached version of the homepage? Seems having two cached versions creates a conflict?
This problem only happens with Firefox (I have ver 29.0.1). It does not happen on IE ver 11, Chrome ver 34, or Safari ver 5.1.7.
I get the same problem with XP, Win7, and Win8 but, only on Firefox.
Can you please fix this?Hey, I am trying to reproduce this here: [http://jsfiddle.net/u3TLb/]
Mozillazine forums and the [http://webcompat.com] are more specialized in Web Compatibility, please ask there as well. -
How to make shape rotation at it's center point?
I draw a shape,like follows:
var shape1:Shape;
shape1=draw();
addChild(shape1);
shape1.rotation=50;
private function draw():Shape{
var shape:Shape = new Shape();
shape.graphics.beginFill(0x00FFFF);
shape.graphics.moveTo(200,200);
shape.graphics.lineTo(300, 202);
shape.graphics.lineTo(200, 204);
shape.graphics.lineTo(100, 202);
shape.graphics.lineTo(200, 200);
return shape;
Then I want to rotate the shape at it's center point(200,202) by using shape1.rotation=50,but I find the shape don't rotate at the the center of it's shape. How to realize the function which make shape rotate at its center point?
ThanksHere is a sample to make it rotate from center:
var sprite:Sprite=new Sprite();
sprite.graphics.lineStyle(3,0x00ff00);
sprite.graphics.beginFill(0x0000FF);
sprite.graphics.moveTo(0,0);
sprite.graphics.lineTo(100,0);
sprite.graphics.lineTo(100,100);
sprite.graphics.lineTo(0,100);
sprite.graphics.lineTo(0,0);
sprite.graphics.endFill();
var mc:Sprite=new Sprite();
mc.addChild(sprite);
//This will make the sprite to center
mc.getChildAt(0).x=-(mc.getChildAt(0).width/2);
mc.getChildAt(0).y=-(mc.getChildAt(0).height/2);
addChild(mc);
mc.x=200;
mc.y=300;
//Now it rotates from the center.
mc.rotation=20; -
Problem using stopDrag function
hi there, im trying to put a simple circle over another circle (bigcircle with diferent x and y coordinates) but i got an error when i release the circle outside the bigcircle
TypeError: Error #1009: Cannot access a property or method of a null object reference
the 2 movieclip circles r in the stage ...
help plz
import flash.display.MovieClip;
import flash.events.MouseEvent;
smallcircle.addEventListener(MouseEvent.MOUSE_DOWN, dragit);
smallcircle.addEventListener(MouseEvent.MOUSE_UP, stopit);
function dragit(event:MouseEvent):void
smallcircle.startDrag();
function stopit(event:MouseEvent):void
smallcircle.stopDrag();
if (smallcircle.dropTarget.parent == bigcircle)
trace("Ok");
else
smallcircle.x = 90;
smallcircle.y = 315;Try adding a conditional to test if there's a dropTarget...
if (smallcircle.dropTarget && smallcircle.dropTarget.parent == bigcircle) -
How to add fade element to rotating banner (javascript)
Hi! I'd like to add a fade element to a rotating banner. Does anyone have any ideas? My code is as follows:
HTML:
<div style="position:absolute; z-index:2;">
<a href="linkPage.html"><img src="images/factoryhack2v3.jpg" width="1136" height="285" id="adBanner" border="0"/></a>
</div>
Javascript:
window.onload = initBannerLink;
var adImages = new Array("images/img1.jpg","images/img2.jpg","images/img3.jpg");
var adURL = new Array("URL here","URL here");
var thisAd = 0;
function rotate() {
thisAd++;
if (thisAd == adImages.length) {
thisAd = 0;
document.getElementById("adBanner").src = adImages[thisAd];
setTimeout("rotate()", 3 * 3000);
function newLocation() {
document.location.href = "http://www." + adURL[thisAd];
return false;
function initBannerLink() {
if (document.getElementById("adBanner").parentNode.tagName == "A") {
document.getElementById("adBanner").parentNode.onclick = newLocation;
rotate();
Thanks so much in advance for any assistanceLots of different effects for rotating banners are built in to these jQuery plugins:
Cycle2
http://www.malsup.com/jquery/cycle2/
Wow Slider
http://wowslider.com/
Nancy O. -
I have a canvas on which i drag and drop an image and user
has an option to rotate it. When image is rotated using
mx.effects.Rotate it adds extra space to canvas size.. means
increases maximum horizontal and vertical scroll positions. After
banging my head with walls I dropped the idea of rotating it with
effect and used the following code, but it also showed the same
problem. I do not want to use BitmapData to redraw as do not want
to lose image quality. Also image size needs to be adjusted after
rotation. Please help, badly stuck :(
var m : Matrix = img.transform.matrix;
var p:Point = m.transformPoint(new Point(img.width/2,
img.height/2));
m.translate(-p.x, -p.y);
m.rotate(angle)
m.translate(p.x, p.y);
img.transform.matrix = m;I have concluded that BitmapData does not reduce the image
quality. So got the solution to my problem, please find attached
the code, might help someone.
first of all
//duplicate image.content as Bitmap and save for further use
in Rotation
var imageBitmapData : BitmapData =
Bitmap(image.content).bitmapData;
image.data.content = new Bitmap(imageBitmapData);
//then use the following method for rotating image
private function rotateImage(image: Image, degrees : Number)
: void {
image.addEventListener("sourceChanged",
onImageLoadCompleteHandle);
var matrix : Matrix = getRotatedMatrix(image, degrees);
this. image.source = getBitmapImageOfRotatedMatrix(image,
matrix, degrees);
//gets the rotated matrix for a new Matrix();
private function getRotatedMatrix(image : Image, degrees :
Number) : Matrix {
var radians : Number = degreesToRadians(degrees);
var m : Matrix = new Matrix();
var p:Point = m.transformPoint(new
Point(image.data.content.width/2, image.data.content.height/2));
m.translate(-p.x, -p.y);
m.rotate(radians);
if ((degrees == 90) || (degrees == -90)) {
m.translate(p.y, p.x);
} else {
m.translate(p.x, p.y);
return m;
* Pass in reference to of the Image control with the
original image and the matrix
* @param img
* @param matrix
* @return
private function getBitmapImageOfRotatedMatrix(img:Image,
matrix:Matrix, degrees : Number) : Bitmap {
var bd:BitmapData;
try {
if ((degrees == 90) || (degrees == -90)) {
bd = new BitmapData(img.data.content.height,
img.data.content.width);
} else {
bd = new BitmapData(img.data.content.width,
img.data.content.height);
bd.draw(img.data.content, matrix);
var bmp : Bitmap = new Bitmap(bd);
} catch (err : Error) {
Alert.show(err.message + "\n" + err.getStackTrace());
return bmp;
this method resizes my image to the size of container with
respect to the following logic, if someone is interested in the
methods used in the code, please let me know
//if (container.width >= container.height) {
//image.width = container.width;
//image.height = (1/aspectRatioOf-ImageContent) *
container.width;
//else if (container.height > container.width) {
//image.height = container.height;
//image.width = aspectRatioOf-ImageContent *
container.height;
private function onImageLoadCompleteHandle(event : Event) :
void {
img.maintainAspectRatio = false;
var imageDim : Dimension = new Dimension(img.height,
img.width);
var parentDim : Dimension = new Dimension(img.parent.width,
img.parent.height);
var newDimensions : Dimension =
UIDrawing.getImageNewDimensions(imageDim, parentDim);
img.width = newDimensions.Width;
img.height = newDimensions.Height;
img.removeEventListener("sourceChanged",
onImageLoadCompleteHandle); -
How do I show multiple images when I hover over different areas with the MouseOver function?
I’ve been working on a flash simulator to show what our Expert Range Finder binocular product would look like. The idea is to hover over an area, or image and it show the range or how far the object is from you.
I have been successful in making it work with the following code below. Yet I cannot add several "range" images (or symbols) when I hover over a certain area. Can someone help me with the code? I looked for hours on the internet and I cannot get it to work. I am new to Flash but am starting to learn as much as I can. Any help is appreciated! Thanks!
Actionscript 3 Code:
img_nv.mask = mask2_mc;
mask2_mc.buttonMode=true;
mask2_mc.addEventListener(MouseEvent.MOUSE_DOWN, onDown);
mask2_mc.addEventListener(MouseEvent.MOUSE_UP, onUp);
function onDown(e:MouseEvent):void{
mask2_mc.startDrag();
function onUp(e:MouseEvent):void{
mask2_mc.stopDrag();Ned:
I can't thank you enough for your help! I just have a few questions left if you don't mind.
If you look at the picture, the text shows up in the "tfield" yet there is a weird symbol after "37Y" that I cannot get rid of. In the code I erased in line 29 " + " zone" " Is that the reason why it is showing a weid symbol?
One more question. I tried placing multiple ranges and text fields and they are not working. All I did was duplicate the code for the first range and text like below but I am missing something. Will you kindly help me?
Actionscript Code:
range2.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
range2.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
function manageMouseOver(event:MouseEvent):void{
tfield2.text = "over "+ event.currentTarget.name + " zone";
function manageMouseOut(event:MouseEvent):void{
tfield2.text = "";
range3.addEventListener(MouseEvent.ROLL_OVER, manageMouseOver, false, 0, true);
range3.addEventListener(MouseEvent.ROLL_OUT, manageMouseOut, false, 0, true);
function manageMouseOver(event:MouseEvent):void{
tfield3.text = "over "+ event.currentTarget.name + " zone";
function manageMouseOut(event:MouseEvent):void{
tfield3.text = "";
. . . .and so on for two more ranges and text fields. -
hello
i want to create a cone and let it move from
position to another position and also i want to rotate the cone in the
direction of the second position
i do the move from the position to the second position using
KBRotPosScaleSplinePathInterpolator but i can't rotate the cone head
into the direction of the second point
i use thecode of rotation of objects using transform 3d but it doesn't
work could u help me
this is the code for creating objects and rotating it
for(int i=0;i<count;i++)
Transform3D t3d=new Transform3D();
//t3d.set(new Vector3f(0.0f,0.0f,0.0f));
double rotAngle = calcTurn(new Point3d(pos1), new Point3d(pos0));
System.out.println("rotation angle is "+rotAngle);
TransformGroup tg=new TransformGroup(t3d);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
Cone c = new Cone(0.05f,.1f, redApp);
doRotateY(rotAngle,tg,t3d);
tg.addChild(c);
KBKeyFrame []KKF1;
KKF1=setupLinearKeyFrames(1,0);
Alpha a1=setupAnimationData(i,(5000*i)/10);
createInterpolators(tg,KKF1,a1);
rootBranchGroup.addChild(tg);
i calculate the angle between 2 positions using this function
private double calcTurn(Point3d alienLoc, Point3d touristLoc)
/* Calculate the angle to turn the alien around the
y-axis, so that it is facing towards the tourist.
This angle is relative to the original orientation
facing along +z-axis
{ // printTuple(alienLoc, "alienLoc");
// printTuple(touristLoc, "touristLoc");
double zDiff = touristLoc.z - alienLoc.z;
double xDiff = touristLoc.x - alienLoc.x;
//System.out.println("xDiff: " + df.format(xDiff) +
// "; zDiff: " + df.format(zDiff) );
double turnAngle = 0.0; // the angle to rotate the alien
if (zDiff != 0.0) {
double angle = Math.atan( xDiff/zDiff);
// the angle from alienLoc to touristLoc
// System.out.println("angle: " + df.format(angle));
if ((xDiff > 0) && (zDiff > 0)) // some redundancy for clarity
turnAngle = angle;
else if ((xDiff > 0) && (zDiff < 0))
turnAngle = Math.PI + angle; // since angle has neg value
else if ((xDiff < 0) && (zDiff < 0))
turnAngle = Math.PI + angle;
else if ((xDiff < 0) && (zDiff > 0))
turnAngle = angle; // since angle has neg value
else { // zDiff == 0.0, which is unlikely with doubles
if (xDiff > 0)
turnAngle = Math.PI/2;
else if (xDiff < 0)
turnAngle = -Math.PI/2;
else // alien and sprite at *exact* same place
turnAngle = 0.0;
// System.out.println("turnAngle: " + df.format(turnAngle));
return turnAngle;
} // end of calcAngle()then do rotation by this function
public void doRotateY(double radians,TransformGroup objectTG, Transform3D t3d)
// Rotate the sprite by radians amount around its y-axis
objectTG.getTransform( t3d );
//toRot.setIdentity();
Transform3D toRot=new Transform3D();
toRot.rotY(radians); // overwrite previous rotation
t3d.mul(toRot);
objectTG.setTransform(t3d);
} // end of doRotateY()hello
i want to create a cone and let it move from
position to another position and also i want to rotate the cone in the
direction of the second position
i do the move from the position to the second position using
KBRotPosScaleSplinePathInterpolator but i can't rotate the cone head
into the direction of the second point
i use thecode of rotation of objects using transform 3d but it doesn't
work could u help me
this is the code for creating objects and rotating it
for(int i=0;i<count;i++)
Transform3D t3d=new Transform3D();
//t3d.set(new Vector3f(0.0f,0.0f,0.0f));
double rotAngle = calcTurn(new Point3d(pos1), new Point3d(pos0));
System.out.println("rotation angle is "+rotAngle);
TransformGroup tg=new TransformGroup(t3d);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_WRITE);
tg.setCapability(TransformGroup.ALLOW_TRANSFORM_READ);
Cone c = new Cone(0.05f,.1f, redApp);
doRotateY(rotAngle,tg,t3d);
tg.addChild(c);
KBKeyFrame []KKF1;
KKF1=setupLinearKeyFrames(1,0);
Alpha a1=setupAnimationData(i,(5000*i)/10);
createInterpolators(tg,KKF1,a1);
rootBranchGroup.addChild(tg);
i calculate the angle between 2 positions using this function
private double calcTurn(Point3d alienLoc, Point3d touristLoc)
/* Calculate the angle to turn the alien around the
y-axis, so that it is facing towards the tourist.
This angle is relative to the original orientation
facing along +z-axis
{ // printTuple(alienLoc, "alienLoc");
// printTuple(touristLoc, "touristLoc");
double zDiff = touristLoc.z - alienLoc.z;
double xDiff = touristLoc.x - alienLoc.x;
//System.out.println("xDiff: " + df.format(xDiff) +
// "; zDiff: " + df.format(zDiff) );
double turnAngle = 0.0; // the angle to rotate the alien
if (zDiff != 0.0) {
double angle = Math.atan( xDiff/zDiff);
// the angle from alienLoc to touristLoc
// System.out.println("angle: " + df.format(angle));
if ((xDiff > 0) && (zDiff > 0)) // some redundancy for clarity
turnAngle = angle;
else if ((xDiff > 0) && (zDiff < 0))
turnAngle = Math.PI + angle; // since angle has neg value
else if ((xDiff < 0) && (zDiff < 0))
turnAngle = Math.PI + angle;
else if ((xDiff < 0) && (zDiff > 0))
turnAngle = angle; // since angle has neg value
else { // zDiff == 0.0, which is unlikely with doubles
if (xDiff > 0)
turnAngle = Math.PI/2;
else if (xDiff < 0)
turnAngle = -Math.PI/2;
else // alien and sprite at *exact* same place
turnAngle = 0.0;
// System.out.println("turnAngle: " + df.format(turnAngle));
return turnAngle;
} // end of calcAngle()then do rotation by this function
public void doRotateY(double radians,TransformGroup objectTG, Transform3D t3d)
// Rotate the sprite by radians amount around its y-axis
objectTG.getTransform( t3d );
//toRot.setIdentity();
Transform3D toRot=new Transform3D();
toRot.rotY(radians); // overwrite previous rotation
t3d.mul(toRot);
objectTG.setTransform(t3d);
} // end of doRotateY()
Maybe you are looking for
-
Hello to all, I am using LV 8.2 to create an installer for a program thta I created. The one problem that I am running into is that the EXE, everytime I run it, is looking for a dll file that I used when creating the EXE. I loaded the dll and it stil
-
Editing /etc/squirrelmail/config/conf.pl while Mail server is running
Do you advise stopping mail services before editing the conf.pl file?
-
What products to choose for a SOA and BPM Scenario?
Hi, i am beggining in this interesting world of SOA and BPM. I am responsible for evaluating to implement a business testing case of SOA and BPM that involves these products: Oracle BPM, Oracle Service Bus, Oracle BPEL, Oracle Weblogic Server. So, i
-
Hi I've got a couple scanned documents and all of the sudden the file got too big. How can i reduce the file? THX Christian
-
Duplicate Post, Sorry!
Dupe, admin please delete.