dlw1 | 29 Jul 21:09
Favicon

Menu Functions

Hi,

We're essentially trying to alter the menu above the simple demo world to include actions to create and
manipulate objects in the world. As an exploratory step in this, I created an "Actions" menu that has an
item "Create snowman" in it. This creates three movable spheres in the world every time it is pressed. 

What we then wanted to do was have another option in the same menu "Animate head" that would move the head away
from the body and then bring it back. This is a very simple animation, however, the issue we are running into
is that we know of no way to reference this sphere so that the menu knows what we're talking about. 

Is this territory that has been covered in the past? Is it simply not currently possible to use the menu as a
viable way to change the scene? Or am I missing something simple that would allow us to do just this?

Thanks,

Dan

Andreas Raab | 29 Jul 22:54

Re: Menu Functions

Well, in general, if you want to have one menu item to create an object 
and another one to manipulate it, you'll have to remember the object you 
created somewhere. For example, this could be done via:

menuActionCreateSnowman
   "Create the snowman and remember it in the 'snowman' variable"
   snowman := island future new: TSnowman. "create TSnowman"
   space future addChild: snowman. "add it to the space"

menuActionMoveSnowmanHead
   "Move the head of the snowman"
   snowman future moveHead.

The above assumes that there is a TSnowman (subclass of TFrame) which 
implements the snowman object and has a method #moveHead that moves the 
head in the way you'd like.

Hope this helps,
   - Andreas

dlw1 <at> williams.edu wrote:
> Hi,
> 
> We're essentially trying to alter the menu above the simple demo world to include actions to create and
manipulate objects in the world. As an exploratory step in this, I created an "Actions" menu that has an
item "Create snowman" in it. This creates three movable spheres in the world every time it is pressed. 
> 
> What we then wanted to do was have another option in the same menu "Animate head" that would move the head
away from the body and then bring it back. This is a very simple animation, however, the issue we are running
into is that we know of no way to reference this sphere so that the menu knows what we're talking about. 
(Continue reading)

Phua Khai Fong | 7 Aug 00:37
Favicon

Re: Menu Functions


Hi,

Another way you could do it is to use the pointerDown: method. Enable the
sphere to respond to mouse events then you can put in the functions in
pointerDown:. So the head can be moved by just clicking on it. This should
be much simpler if you consider having multiple snowman where you will not
need to keep track of each of them and determine which one to move compared
to the menu function.

dlw1 wrote:
> 
> Hi,
> 
> We're essentially trying to alter the menu above the simple demo world to
> include actions to create and manipulate objects in the world. As an
> exploratory step in this, I created an "Actions" menu that has an item
> "Create snowman" in it. This creates three movable spheres in the world
> every time it is pressed. 
> 
> What we then wanted to do was have another option in the same menu
> "Animate head" that would move the head away from the body and then bring
> it back. This is a very simple animation, however, the issue we are
> running into is that we know of no way to reference this sphere so that
> the menu knows what we're talking about. 
> 
> Is this territory that has been covered in the past? Is it simply not
> currently possible to use the menu as a viable way to change the scene? Or
> am I missing something simple that would allow us to do just this?
> 
(Continue reading)


Gmane