Change a actors size if collision with another actor - just can't get it to work!
Zombiebrains
www.zombiebrains.co.ukMember, PRO Posts: 296
Hi all
I am making a retro arcade game and I have a graphic for earth in the background - attributes are Width = 160 / height = 160
How I have it so if the missiles are not destroyed on the game grid they go off the top of the screen and out of sight turn 180 degrees and head for he earth actor (Smaller in size to give distance impression) in the middle of the screen.
I also have a rule to turn true if the missile goes out of screen and returns back on, or as soon as the missile hits the earth before flying off screen it changes the size...this rule is called ALIEN ALIVE
Now, I want it so that if the actor missile hits actor earth then to change the Earth Width and Earth height by -10 so say after 1 hit the new attributes would be 150 x 150...right i have this working but when I reset the screen the earth actor returns to 160 x 160 which is the original actors size
I have game attributes EARTH WIDTH and EARTH HEIGHT so I have a rule in the Earth actor
when earth actor collides with ALIEN and ALIEN ALIVE is true then contain attribute self actor width to EARTH WIDTH -10 and contain attribute self actor height to EARTH HEIGHT -10.
I have tried spawning the actor on screen every time the scene is reset and so had it placed on screen but it won't change the size every time with the new EARTH WIDTH and EARTH HEIGHT when a alien missile hits it..
Any clues?
Thanks guys...
I am making a retro arcade game and I have a graphic for earth in the background - attributes are Width = 160 / height = 160
How I have it so if the missiles are not destroyed on the game grid they go off the top of the screen and out of sight turn 180 degrees and head for he earth actor (Smaller in size to give distance impression) in the middle of the screen.
I also have a rule to turn true if the missile goes out of screen and returns back on, or as soon as the missile hits the earth before flying off screen it changes the size...this rule is called ALIEN ALIVE
Now, I want it so that if the actor missile hits actor earth then to change the Earth Width and Earth height by -10 so say after 1 hit the new attributes would be 150 x 150...right i have this working but when I reset the screen the earth actor returns to 160 x 160 which is the original actors size
I have game attributes EARTH WIDTH and EARTH HEIGHT so I have a rule in the Earth actor
when earth actor collides with ALIEN and ALIEN ALIVE is true then contain attribute self actor width to EARTH WIDTH -10 and contain attribute self actor height to EARTH HEIGHT -10.
I have tried spawning the actor on screen every time the scene is reset and so had it placed on screen but it won't change the size every time with the new EARTH WIDTH and EARTH HEIGHT when a alien missile hits it..
Any clues?
Thanks guys...
It takes a Zombie to know a Zombie!!!
Comments
Sorry, a bit of a newbie on this stuff....
How do I do that exactly? not heard of SIC action?
It takes a Zombie to know a Zombie!!!
It takes a Zombie to know a Zombie!!!
Yep, a Change Attribute behavior instead of the Constrain behavior is what Socks is trying to say.
My GameSalad Academy Courses! ◦ Check out my quality templates! ◦ Add me on Skype: braydon_sfx
Basically, I was suggesting you change the constrain attribute behaviour for a change attribute behaviour . . . .
Thanks for your updates.
I have tried the change attribute too but no joy.
It does work when the missile it the earth actor but then when I reset the scene the actor resumes it's original size of 160 x 160.
I must be doing something totally wrong....?
So I have an actor which is 160 x 160, if missile hits it takes 10 off both then the game resets and another wave of missiles come in...but when the new scene starts the earth actor resizes back to 160 x 160.
I have it so change self.size.width to earth.width -10 and the same with the height...it changes once but then it uses the original actor size when the scene is reset...
Sorry to ask but it should be simple but I can't see what's wrong?
It takes a Zombie to know a Zombie!!!
That sounds right, resetting the scene will reset all the values in that scene.
Complete Guide to iOS Publishing {} Complete Guide to Mac Publishing
Example file attached below . . .
Basically you need to make a couple of game attributes (i.e. a couple of attributes that are 'outside' the scene and won't be effected when all the scene values are reset by the reset scene behaviour) . . . these attributes track the width and height of the earth . . . (actually because it's 160 x 160 and the width and height goes down by 10 pixels every time it's hit, you really only need one attribute . . . but let's ignore that for the moment) . . . . these game attributes keep track of the size of the earth, so even when you reset the scene, the game attributes can tell the actor what size it was before the scene was reset.
Like this. . . . Scene runs . . .
4 attributes, earth height and width . . . . and 'stored number' X and Y.
>
1) Missile is fired, it hits the earth.
2) So we change earth height and earth width to . . . earth height-10 and earth width-10.
3) We also change 'stored number' X to the current earth height value and 'stored number' Y to the current earth width value.
Now we reset the scene, all values are lost.
But at the top of the earth's rules are two change attribute behaviours which say:
Change self.x to 'stored number' X
Change self.y to 'stored number' Y
...
Note: when you set this up make sure the stored number x and y values are set to 160 by default.
WOW....your a truly amazing guy. Thank you so much for sorting that out and more importantly taking the time to show me on your example...makes sense now and it now works a treat.
I thank you so much and taking time to help me....works a treat now!
Truly thank you so much...will keep that as an example for future projects.
ZB
It takes a Zombie to know a Zombie!!!