|
-
for loop and hittest
Hi,
I use arrow keys to collect five apples . I used hittest to make the collected apples invisible but there is a simple problem I can not fix..
thanks for any help
PHP Code:
for(gi=0;gi<=5;gi++)
{
if(this.kare.hitTest(this.apple+gi)){
this.apple+gi._visible=false;
}
-
trace("AKA: Biro Barna");
I have no idea what are trying to do with that code.

| Windows MSN: birobarna [at] hotmail [dot] com | Skype: barna.biro | WebLog: http://blog.wisebisoft.com/ |
| Software Developer / Flash & Flex Developer | Student ( Computer Science ) | Interested in: Sharing Knowledge |
| Romanian Adobe Flash, Flex, AIR Forum: http://www.flashforum.ro/ | By perseverance the snail reached the ark. |
-
I may be completely wrong but you might need to change... it into this:
for(gi=0;gi<=5;gi++)
{
if(this.hitTest(this.apple+[gi])){
this.apple+[gi]._visible=false;
}
What i did was remove "kare" and change "gi" to "[gi]".
If you have only five apples you can hitTest each one rather than using the extra variables, just a suggestion but if you want to use
"for(gi=0;gi<=5;gi++) " then its fine but it'll be slightly complicated.
-
Oh whoops, maybe you might want to change this.apple + [gi] to [ this.apple + gi ]
My code is similar to that...I also am having hitTest problems in my game.
-
Anyother suggetion please help..
for(gi=0;gi<=5;gi++)
{
if(this.kare.hitTest(this.apple+gi)){
this.apple+gi._visible=false;
}
}
my Hittest is supposed to work for more objects of same name...
Is there a method like ..getElementById().. flash..?
may be that way I can make it work ?
thanks
-
http://www.in3d.eu
Hi,
Just if this the case: want to access multiple objects with names "apple0", "apple1", etc.. If yes, then try something like this:
(AS):
PHP Code:
for(gi=0;gi<=5;gi++) {
var mc=this["apple"+gi]
if(this.kare.hitTest(mc)){
mc._visible=false;
}
}
Kostas
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|