func pressButton(b *staticimg.StaticImg, u *uistate.UIState) { if !b.GetHidden() { u.Eng.SetSubTex(b.GetNode(), b.GetAlt()) b.SetHidden(false) b.SetDisplayingImage(false) } }
func AlternateImgs(s *staticimg.StaticImg, u *uistate.UIState) { <-time.After(100 * time.Millisecond) node := s.GetNode() node.Arranger = arrangerFunc(func(eng sprite.Engine, node *sprite.Node, t clock.Time) { t0 := uint32(t) % 10 if t0 < 5 { u.Eng.SetSubTex(s.GetNode(), s.GetImage()) } else { u.Eng.SetSubTex(s.GetNode(), s.GetAlt()) } }) }
// checks one specific drop target to see if a card was dropped there func dropCardHere(c *card.Card, d *staticimg.StaticImg, t touch.Event, u *uistate.UIState) bool { if !touchingStaticImg(t, d, u) { return false } lastDroppedCard := d.GetCardHere() if lastDroppedCard != nil { reposition.ResetCardPosition(lastDroppedCard, u.Eng) reposition.RealignSuit(lastDroppedCard.GetSuit(), lastDroppedCard.GetInitial().Y, u) } oldY := c.GetInitial().Y suit := c.GetSuit() u.CurCard.Move(d.GetCurrent(), c.GetDimensions(), u.Eng) d.SetCardHere(u.CurCard) // realign suit the card just left reposition.RealignSuit(suit, oldY, u) return true }
func RemoveImg(s *staticimg.StaticImg, u *uistate.UIState) { u.Eng.Unregister(s.GetNode()) }
func touchingStaticImg(t touch.Event, s *staticimg.StaticImg, u *uistate.UIState) bool { withinXBounds := t.X/u.PixelsPerPt >= s.GetCurrent().X && t.X/u.PixelsPerPt <= s.GetDimensions().X+s.GetCurrent().X withinYBounds := t.Y/u.PixelsPerPt >= s.GetCurrent().Y && t.Y/u.PixelsPerPt <= s.GetDimensions().Y+s.GetCurrent().Y return withinXBounds && withinYBounds }
func AnimateImageNoChannel(animImage *staticimg.StaticImg, endPos, endDim *coords.Vec, u *uistate.UIState) { node := animImage.GetNode() startPos := animImage.GetCurrent() startDim := animImage.GetDimensions() iteration := 0 node.Arranger = arrangerFunc(func(eng sprite.Engine, node *sprite.Node, t clock.Time) { iteration++ if iteration < animationFrameCount { curXY := animImage.GetCurrent() curDim := animImage.GetDimensions() XYStep := endPos.MinusVec(startPos).DividedBy(animationFrameCount) dimStep := endDim.MinusVec(startDim).DividedBy(animationFrameCount) newVec := curXY.PlusVec(XYStep) dimVec := curDim.PlusVec(dimStep) animImage.Move(newVec, dimVec, eng) card := animImage.GetCardHere() if card != nil { card.Move(newVec, dimVec, eng) } } else if iteration == animationFrameCount { animImage.Move(endPos, endDim, eng) card := animImage.GetCardHere() if card != nil { card.Move(endPos, endDim, eng) } } }) }