Jump to content


Photo

Instance_activate_region Help?


  • Please log in to reply
4 replies to this topic

#1 mws_1991

mws_1991

    GMC Member

  • New Member
  • 195 posts

Posted 23 December 2009 - 02:57 AM

just checking what instance_activate_region does exactly... to my knowledge it can be used to activate or deactivate instances that are within the distances(parameters) you set...

im using:

instance_activate_region(view_xview-64,view_yview-64,view_wview+(64*2),view_hview+(64*2),true);
instance_deactivate_object(objEnemy);

however the objEnemy will only appear ingame if the objPlayer.y is below the objEnemy.y is there something wrong with the code im using?
I want to make it so that the enemy will activate just outside the view area so that it is moving etc once it actually appears on screen. The view is 320x240

Any help is appreciated!
  • 0

#2 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1126 posts
  • Version:GM7

Posted 23 December 2009 - 03:27 AM

Move the instance_deactivate above the instance_activate_region. View_wview and view_hview refer to the width and height of the view. You will want
[codebox]
instance_deactivate_object(objenemy)
instance_activate_region(view_xview-64,view_yview-64,view_xview+view_wview+128,view_yview+view_hview
+128,true)
[/codebox]
I don't know why you have 64*2 and not replace it with 128...
  • 0

#3 mws_1991

mws_1991

    GMC Member

  • New Member
  • 195 posts

Posted 23 December 2009 - 03:38 AM

That works for when player.y is below enemy.y but now it doesnt work if the player is above the enemy :S
the whole problem only started happening once i changed from 640x480 to 320x240...

EDIT: I'm also using a view code in the player end step event... i dont know if it might be affecting the above code?

objPlayer, end step:
//VIEW MOVEMENT
if view_xview>x-330 and view_xview<x-310 {view_xview=x-320;} else {
	if view_xview<x-330 {view_xview+=5}
	if view_xview>x-320 {view_xview-=5}
}
view_yview=y-240;
if view_xview<0 {view_xview=0}
if view_yview<0 {view_yview=0}
if view_xview>room_width-320 {view_xview=room_width-320;}
if view_yview>room_height-240 {view_yview=room_height-240;}

the code in my first post is under objControl in the end step event...

Edited by mws_1991, 23 December 2009 - 03:41 AM.

  • 0

#4 smash ball

smash ball

    Volcanic Light

  • GMC Member
  • 1126 posts
  • Version:GM7

Posted 23 December 2009 - 03:42 AM

Why don't you have the view follow the player object in the view settings for the room, then you won't have this problem.
If you want a simple view follow code then:
[codebox]
view_xview=x-320
view_yview=y-240
if view_xview<0 then
view_xview=0
if view_yview<0 then
view_yview=0
if view_xview+view_wview>room_width then
view_xview=room_width-view_wview
if view_yview+view_hview>room_height then
view_yview=room_height-view_hview
[/codebox]
EDIT forget the below for now.
Does view_xview+320+128 and view_yview+240+128 work?
Do you have any other code you can post?
Give out all of the view settings.

Edited by smash ball, 23 December 2009 - 03:46 AM.

  • 0

#5 mws_1991

mws_1991

    GMC Member

  • New Member
  • 195 posts

Posted 23 December 2009 - 04:39 AM

wow silly me :(
i was using a custom view when i was already using a view for the room -.- guess doing that makes things buggy... all i had to do was remove the custom view code from my player and it works fine! *sigh* note to self: stop making silly mistakes!

thanks for all the help though smash ball
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users