View Full Version : [AS2] creating custom wall
Cozlaw
01-04-2009, 07:35 PM
How would you go about creating a custom wall in actionscript? (not a circle or a square) Like a custom drawn thing.
Like say you had a player (circle) with an instance name of "player" and you had a drawn wall with an instance name of "wall". How would you make the wall a true wall or barrier?
orange gold
01-06-2009, 03:29 AM
_root.onEnterframe = funciton() {
if (player.hitTest(_root.wall)) {
// code that happens when it hits the wall goes here
}
}
Except not really because of bounding boxes.
orange gold
01-06-2009, 04:12 AM
ive seen a function before to get rid of bounding boxes.. i cant think of it at the moment but its somehting along the lines of shapeFlag or something and looks like this
if (player.hitTest(_root.wall._x, _root.wall._y, true)) {
theclincher
01-06-2009, 04:30 AM
You may want to check this out for your bounding boxes troubles: http://troygilbert.com/2007/06/25/pixel-perfect-collision-detection-in-actionscript3/
Oh, oops, you want AS2: http://www.gskinner.com/blog/archives/2005/10/source_code_sha.html
orange gold
01-06-2009, 04:35 AM
ok... found my old code xD
this gets rid of bounding boxes...
draw an odly shaped object... call it square1
then draw a circle call it square2
both of thoose were instance names btw...
now add this code to fram one and test it out.... NO BOUNDING BOXES!
_root.onEnterFrame = function() {
circle.onPress = function() {
this.startDrag();
}
circle._alpha = 100;
if (_root.square1.hitTest(square2._x, square2._y, true)) {
circle._alpha = 20;
}
}
orange gold
01-06-2009, 02:49 PM
sry here is the real code!
_root.onEnterFrame = function() {
square2.onPress = function() {
this.startDrag();
}
square2._alpha = 100;
if (_root.square1.hitTest(square2._x, square2._y, true)) {
square2._alpha = 20;
}
}
Cozlaw
01-06-2009, 05:45 PM
Thank you for your code snippet, it helps! :D
Problem solved!
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.