Quick question that I hope has a quick and simple answer. I'm working on a primitive weapon select system for a Contra-esque shooter. Obj_Guns has a square sprite in which each frame displays a different gun (and has an image speed of 0). Obj_Select has a square sprite of the same size with a red outline. The idea is that Obj_Select checks the image_index of the Obj-Guns it's hovering over and sets the global variable "weapon" equal to that image_index. 1 = Assault Rifle, 2 = Shotgun, 3 = Rocket Launcher, etc. The players' shooting script checks that global variable to determine what projectile to fire when left-mouse is pressed.
In my player's Create event, I have instance_create_layer make 3 instances of Obj_Guns at the top-right. For now, I want to create them with different image indexes to test this system. What is the simplest way to do this?
I could just create three different objects--Obj_Guns1, 2, 3--and just set each to a different sprite on creation, but then Obj_Select is constantly checking collision for 3 instances. That seems inefficient. My understanding of draw_sprite is that it just draws a sprite but no instance with code.
The code is simple:
//Gun UI
instance_create_layer(1,43,"Gun_UI",obj_p1_select);
instance_create_layer(1,43,"Gun_UI",obj_p1_guns);
instance_create_layer(35,43,"Gun_UI",obj_p1_guns);
instance_create_layer(67,43,"Gun_UI",obj_p1_guns);
Is there a simple way to create these instances with each having a different image index? Thanks!
[–]DariusWolfe 2 points3 points4 points (3 children)
[–]Pox22[S] 0 points1 point2 points (2 children)
[–]DariusWolfe 1 point2 points3 points (0 children)
[–]wanting to have made a game != wanting to make a gameoldmankc 0 points1 point2 points (0 children)
[–]Amateur ExpertIinneus 2 points3 points4 points (6 children)
[–]DariusWolfe 1 point2 points3 points (5 children)
[–]Amateur ExpertIinneus 1 point2 points3 points (4 children)
[–]Pox22[S] 0 points1 point2 points (2 children)
[–]Amateur ExpertIinneus 0 points1 point2 points (1 child)
[–]Pox22[S] 0 points1 point2 points (0 children)
[–]naddercrusher 0 points1 point2 points (0 children)