image_speed?
#1
Posted 24 April 2012 - 01:22 AM
I've tried obj_balljump.image_speed = 2 in the create event and the step event of obj_balljump...but it changes the speed of both objects. How do I set image_speed specifically to obj_balljump so it doesn't change the image speed of obj_ballbounce?
#2
Posted 24 April 2012 - 01:26 AM
#3
Posted 24 April 2012 - 01:30 AM
#4
Posted 24 April 2012 - 01:34 AM
so in the create event of obj_balljump, put:
image_speed = 2;
Thats it.
Edited by C_Pike, 24 April 2012 - 01:34 AM.
#5
Posted 24 April 2012 - 01:34 AM
#6
Posted 24 April 2012 - 01:40 AM
copy/paste Object Information in here for both objects
I think the problem is he is referencing the other object: obj_balljump.image_speed = 2
But seeing the code wont hurt.
#7
Posted 24 April 2012 - 01:43 AM
I am embarassed by the solution, but I simply added "image_speed = 1" in the create event of obj_ballbounce.
I am puzzled why GM wouldn't assume a standard image speed. I needed to define it in the object since I changed the speed in the obj_balljump object...
EDIT: is it because when one object changes into another, the new object inherits certain characteristics of the former? This is a good lesson learned.
Edited by GrayKnight2k, 24 April 2012 - 02:08 AM.
#8
Posted 24 April 2012 - 11:33 AM
EDIT: is it because when one object changes into another, the new object inherits certain characteristics of the former? This is a good lesson learned.
Only if the object is the parent of the other which is why The2Banned2One asked. When an object is created, it runs its own create event. You overrode the image_speed by referencing it with another obj_balljump.image_speed = 2 is looking at all instances of ball jump and making them = 2. image_speed = 2 is just setting the current object's image speed to 2.
GameMaker sets the image speed to something pretty quick by default, but you were overriding that.
----
Parents work like:
obj_ballParent:
<create event: image_speed = 2; health = 100; ball_blendColour = c_red;>
obj_ballBounce:
<parent = obj_ballParent>
obj_ballJump
<parent = obj_ballParent>
<create_event: call parent event; image_speed = 1>
All the balls have a blending colour of red, a health of 100, and all except obj ball bounce have an image speed of 2.
So... as you can see, the parent contains all the variables. obj_ballBounce has no variables of its own (its empty, not even a create event). It gets its variables from obj_ballParent.
obj_ballJump also gets its variables from obj_ballParent, but its image speed is different. obj_ballJump needs a create event, but it wants the variables from the parent so it calls the parent event before making its variable image_speed = 1.
If you don't call the parent event when creating a new event in an ancestor object, it will override the parent event completely.
Having parent objects is a good idea as it cuts down on the coding and debugging process considerably.
I hope this was helpful!
Edited by C_Pike, 24 April 2012 - 11:34 AM.
#9
Posted 25 April 2012 - 01:26 AM
#10
Posted 25 April 2012 - 03:20 AM
Yep. When you use instance_change() (orEDIT: is it because when one object changes into another, the new object inherits certain characteristics of the former? This is a good lesson learned.
I hope this helps,
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users











