hi guys,
i have tow quesation…?
first one :
i’m working in big map… i make a buttons to move it right, left, up and down. it works great. tow buttons for zoom in and out and it works too…
i need to make it move with 45 degree when i press up and right… how can i do it, but i don’t want to rotate it.
second:
how can i make zoom with selection… i mean when i press mouse and draw rectangle in somewhere it makes zoom for this area.
Concerning your first question, it depends on your code, really. When I have to do things like that, I usually use temporary variables to store the position change. Something like that:
function listenForKeys(){
if (Key.isDown(Key.LEFT)) yourClip.x=1;
if (Key.isDown(Key.RIGHT)) yourClip.x=-1;
if (Key.isDown(Key.UP)) yourClip.y=1;
if (Key.isDown(Key.DOWN)) yourClip.y=-1;
}
function updatePosition(){
yourClip._x+=yourClip.x;
yourClip._y+=yourClip.y;
}
this.onEnterFrame=function(){
listenForKeys();
updatePosition();
}
Why make something simple when you can obfuscate it? :sure:
No, actually, what I wrote can (could?) be useful if you had to test the position to be sure you’re not out of bounds. Man, I just can’t explain myself today :crazy:
Man… I am sooo bored. I gotta watch my dog today (he just had surgery yesterday) and all he is doing is sleeping!!! Which is normal, but still, sheesh, I need SOMETHING to do here.
I dunno yet, I have NO clues as towhat to make, and my scripting ability with just AS isn’t too hot, especially when trying to keep it withing a certain amount of lines.
You know my code efficiency and optimization sucks
Just checked Jared Tarbells new stuff. Almost wish I hadn’t, now I am just more jealous of him again… :hangover:
I like the walking critters thing, I always wanted to learn how to do that in AS. Any idea on where to learn? Or is it going to be one of those “try and see” type of deals?
LOL, it is Jared Tarbell though! His code is about as readable as Latin converted to Mandarin. Not to mention this particular experiment is OOP :hangover: <-- OOP does that to me.
But he does define everything into a bunch of tiny little functions, which makes it a bit easier to follow.
hi man… this is my code
[AS]
speed = 5;
_root.onEnterFrame = function() {
if (Key.isDown(Key.RIGHT)) {
_root.big_city._x += speed;
} else if (Key.isDown(Key.LEFT)) {
_root.big_city._x -= speed;
} else if (Key.isDown(Key.UP)) {
_root.big_city._y -= speed;
} else if (Key.isDown(Key.DOWN)) {
_root.big_city._y += speed;
}else if (Key.isDown(79)) {
_root.fullmap.map.text_all._visible =0
//_root.logo._visible =0
}else if (Key.isDown(67)) {
_root.fullmap.map.text_all._visible =1
//_root.logo._visible =1
}else if (Key.isDown(90)) {
_root.bag_city._xscale +=10
_root.bag_city._yscale +=10
}else if (Key.isDown(88)) {
_root.bag_city._xscale -=10
_root.bag_city._yscale -=10
}else if (Key.isDown(76)) {
_root.logo._visible =0
}else if (Key.isDown(71)) {
_root.logo._visible =1
}
};
[/AS]
it works good but when i tired you code (&&) i don’t know why it didn’t work.
i didn’t know how to do it with function… i thought about function but i failed…
but now it works… thanx
Well so far thers a ton of different methods of this in this very thread.
But I think the problem here lies in the else if statements.
See, an else if says that if this is false then check this and if this is false then check the one after this. Now, when it finally reaches an if statement that is true, it stops running.
So unless you press both keys at the exact same time, the if statments will stop at the first button pressed and it won’t include the second button.