x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Best way to show sprite based on array

Hi there, so I'm currently learning how to make a simple 2D games on UE4, but trying to figure out how to show sprite on screen based off a click of a button. Simple principle on how I want them to work is: I have made tons of sprites for them with the following name: x-y-z. I have 6 button (2 for each set, total 3 set, previous and next). It's like if you pressed set 1 button it will move the "x" up and down starting from 0-9 and so forth creating tons of possibilities like 1-2-1 or 9-1-2 and so forth.

What I have tried: make an UMG Widget, render them to the viewport and currently only have two working buttons, the buttons to show up images with varying "x" variables. So currently it will only show 1-0-0, 5-0-0 and so forth. The "y" and "z" doesn't move. This is achieved by creating the functions for every sprites I have. Imagine I have to set such a combination from 0-0-0 to 9-9-9?

What I am trying to ask: Are there any easier way to do this? I know that UE4 doesn't have any image arrays (from most of the tutorials I've watched there is no image arrays and haven't seen anyone trying to bother to do what I'm trying to learn).

Thank you in advance and sorry for my bad language, I am not a native English speaker. Also sorry if I were to confuse you, I am starting to learn UE4.

Product Version: UE 4.21
Tags:
more ▼

asked Feb 14 '19 at 04:16 PM in Blueprint Scripting

avatar image

TenzoNakami
5 2 3

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

I was thinking about that i came with two ideas: 1) Create a array from Texture2D objects, and place them as 0-0-1, 0-0-2, ..., 9-9-8, 9-9-9. Then when you click button it will add a 1, 10 or 100 to int, and also it will trigger the change event -> when button pressed, you will switch image to current number.

2) Make 3 variables to each of buttons and set them to add or substract number. Set array of all images you have. Then, combine those variables with append and go with function like this: Switcher . Also, set up the event that will switch image to found one.

more ▼

answered Feb 15 '19 at 01:40 PM

avatar image

SpynderYT
87 3 3 9

avatar image TenzoNakami Feb 15 '19 at 09:04 PM

Awesome! Why I never think about doing it the way you think.. The first option is just too much hassle to me I don't even try to bother with. The second option is way more efficient for me as I am free to add some to test now and add the rest anytime later! Think of scalibility.. Anyway, thank you very much for the idea!

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question